I am trying to create a json response using a for loop and a function but I can't seem to get it to work correctly. How would this be done?
PHP
$count = 0;
foreach ($bookings as $booking){
$item = get_users_custom($user,$count);
$item[$count]['booking_id']=$booking->id;
$count++;
}
echo $item;
function get_users_custom($user,$count=0){
$feed[$count]['user_id']=$user->id;
return $feed;
}