title: Create JSON with function and FOR loop
body: <p>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?</p>
  
  <p>PHP</p>
  
  <pre><code>$count = 0;
  foreach ($bookings as $booking){
  $item = get_users_custom($user,$count);
  $item[$count]['booking_id']=$booking-&gt;id;
  $count++;
  }
  echo $item;
  
  
  function get_users_custom($user,$count=0){
  $feed[$count]['user_id']=$user-&gt;id; 
  return $feed;
  }
  </code></pre>