-8

How to Create Json Like This In Php?

[
 [
  "16226281",
   "11",
   "Disclosure.1994.720p.BluRay.H264.AAC-RARBG",
   "finished"
  ],
  [ 
   "16226038",
   "140",
   "Courage The Cowardly Dog (1999-2002)",
   "finished"
  ],
  [
   "16226020",
   "101",
   "[R.G. Mechanics] Call of Duty 4 Modern Warfare",
   "finished"
  ]
]

I search a lot on the internet but couldn't get any result.

Luca Angioloni
  • 2,243
  • 2
  • 19
  • 28
AirBuddy
  • 1
  • 1

3 Answers3

1
$arr = [
 [
  "16226281",
   "11",
   "Disclosure.1994.720p.BluRay.H264.AAC-RARBG",
   "finished"
],
[ 
  "16226038",
  "140",
  "Courage The Cowardly Dog (1999-2002)",
  "finished"
 ],
 [
  "16226020",
  "101",
  "[R.G. Mechanics] Call of Duty 4 Modern Warfare",
  "finished"
 ]
]


echo json_encode($arr);

Follow below link :

http://php.net/manual/en/function.json-encode.php

Sujal Patel
  • 592
  • 2
  • 5
  • 14
0

Just create an array

<?php
   $arr = array(
       array(
         "16226281",
         "11",
         "Disclosure.1994.720p.BluRay.H264.AAC-RARBG",
         "finished"
       ),
       # ....
     );

and for output as json

 <?php echo json_encode($arr);?>
donald123
  • 5,638
  • 3
  • 26
  • 23
0

Here is an example of JSON encoding using the inbuilt json_encode PHP function which can create JSON formatted data from PHP array:

<?php
$arr = array(
'key 1' => "value 1",
'key 2' => "value 2",
'key 3' => "value 3"
);
echo json_encode($arr);
?>

Source: How to create JSON formatted text in PHP