title: PHP function return multiple JSON object
body: <p>I have a php function that currently looks like this</p>
  
  <pre><code>function renderJson(PageArray $items) {
  $myData = array();
  $myData['title'] = [];
  $myData['url'] = [];
  
  // cycle through all the items
  foreach($items as $item) {
  
      array_push($myData["title"],$item-&gt;title);
      array_push($myData["url"],$item-&gt;url);
  
  
  }
  
  return json_encode($myData);
  }
  </code></pre>
  
  <p>It currently works in this shape as output </p>
  
  <pre><code>{"title":["A","B"],"url":["A","B"]}
  </code></pre>
  
  <p>But this is what I am trying to achieve</p>
  
  <pre><code>{"title":["A"],"url":["A"]},{"title":["B"],"url":["B"]}
  </code></pre>
  
  <p>I am trying to return it as a JSON encode.The $item->title and $item->url returns a string.Any help would be great.</p>