fork download
  1. <?php
  2.  
  3. $json = "{\"table\": [{\"d\":1, \"p\":1, \"m\": \"1\"},{\"d\":2, \"p\":2, \"m\": \"2\"},{\"d\":3, \"p\":3, \"m\": \"3\"}]}";
  4. $jsonA = json_decode($json, false);
  5. $tableA = $jsonA->table;
  6.  
  7. $jsonB = json_decode($json, true);
  8. $tableB = $jsonB['table'];
  9.  
  10. var_dump($tableA);
  11. echo '<br />';
  12. var_dump($tableB);
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
array(3) {
  [0]=>
  object(stdClass)#2 (3) {
    ["d"]=>
    int(1)
    ["p"]=>
    int(1)
    ["m"]=>
    string(1) "1"
  }
  [1]=>
  object(stdClass)#3 (3) {
    ["d"]=>
    int(2)
    ["p"]=>
    int(2)
    ["m"]=>
    string(1) "2"
  }
  [2]=>
  object(stdClass)#4 (3) {
    ["d"]=>
    int(3)
    ["p"]=>
    int(3)
    ["m"]=>
    string(1) "3"
  }
}
<br />array(3) {
  [0]=>
  array(3) {
    ["d"]=>
    int(1)
    ["p"]=>
    int(1)
    ["m"]=>
    string(1) "1"
  }
  [1]=>
  array(3) {
    ["d"]=>
    int(2)
    ["p"]=>
    int(2)
    ["m"]=>
    string(1) "2"
  }
  [2]=>
  array(3) {
    ["d"]=>
    int(3)
    ["p"]=>
    int(3)
    ["m"]=>
    string(1) "3"
  }
}