fork(3) download
  1. <?
  2. $results = array('foo'=>'Foo','bar'=>'Bar','baz'=>'Baz');
  3.  
  4. $final = array('header' => array(), 'data' => array());
  5. $final['header'] = array(
  6. 'title' => 'Test',
  7. 'num' => 5,
  8. 'limit' => 5
  9. );
  10. foreach ($results as $name => $data)
  11. {
  12. $final['data'][] = array(
  13. 'primary' =>'Primary',
  14. 'secondary' => 'Secondary',
  15. 'image' => 'test.png',
  16. 'onclick' => 'alert(\'You clicked on the Primary\');'
  17. );
  18. }
  19. echo json_encode(array($final));
  20. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
[{"header":{"title":"Test","num":5,"limit":5},"data":[{"primary":"Primary","secondary":"Secondary","image":"test.png","onclick":"alert('You clicked on the Primary');"},{"primary":"Primary","secondary":"Secondary","image":"test.png","onclick":"alert('You clicked on the Primary');"},{"primary":"Primary","secondary":"Secondary","image":"test.png","onclick":"alert('You clicked on the Primary');"}]}]