I am developing an application in javascript. Here is my PHP code:
events: [
foreach($requests as $request)
{
if($request->accepted == 'yes') {
echo
"{
id: ". $request->id . ",
start:'". $request->start . "',
end: '". $request->end . "',
},";
}
]
So basically I am taking only id, start and end elements of the object and echoing them as JSON in an array. How would I be able to do the same in javascript foreach loop considering that var requests is the object containing all the data?
NOTE that there is also other data in requests such as price, status in addition to id, start, end but I only want to use id , start and end to be included in my events[] array.