ejemplo de un json - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ejemplo de un json.php

  1. <?php
  2.  
  3. $array = [
  4.     'n1var1' => 125,
  5.     'n1var2' => 'texto1',
  6.     'n1var3' => [
  7.         'n2var1' =>  125,
  8.         'n2var2' => 'texto2',
  9.         'n1var3' => [
  10.             'n3var1' =>  125,
  11.             'n3var2' => 'texto3',
  12.             ], 
  13.         ], 
  14.     ];
  15.     
  16. echo json_encode($array);
  17.  
  18. echo "\n";
  19.  
  20. $array2 = [
  21.     'items' => [
  22.         0 => [
  23.             'itemId'=>7,
  24.             'quantity'=>2,
  25.             ],
  26.         1 => [
  27.             'itemId'=>8,
  28.             'quantity'=>6,
  29.             ],
  30.         ],
  31.     ];
  32.     
  33. echo json_encode($array2);
File Description
  • ejemplo de un json
  • PHP Code
  • 07 Oct-2021
  • 546 Bytes
You can Share it: