3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $chars = explode(", ", "¦, '¨, '?, '´, '¸, 'À, 'Á, 'Â, 'Ã, 'Ä, 'Å"); $products = array(); for($i=0; $i < 10; $i++) { $product = array(); $product["pid"] = $chars[$i]; $products[] = array_map("utf8_decode", $product);; // insert product into array } $data = array( 'success' => 1, 'products' => $products ); $json = json_encode($data, JSON_PRETTY_PRINT);; echo $json; var_dump(json_decode($json, true));
based on YHji4
Output for 5.5.0 - 7.2.0
NULL
Output for 5.4.0 - 5.4.45
{ "success": 1, "products": [ { "pid": "\u00a6" }, { "pid": "'\u00a8" }, { "pid": "'?" }, { "pid": "'\u00b4" }, { "pid": "'\u00b8" }, { "pid": null }, { "pid": "'\u00c1" }, { "pid": null }, { "pid": null }, { "pid": null } ] }array(2) { ["success"]=> int(1) ["products"]=> array(10) { [0]=> array(1) { ["pid"]=> string(2) "¦" } [1]=> array(1) { ["pid"]=> string(3) "'¨" } [2]=> array(1) { ["pid"]=> string(2) "'?" } [3]=> array(1) { ["pid"]=> string(3) "'´" } [4]=> array(1) { ["pid"]=> string(3) "'¸" } [5]=> array(1) { ["pid"]=> NULL } [6]=> array(1) { ["pid"]=> string(3) "'Á" } [7]=> array(1) { ["pid"]=> NULL } [8]=> array(1) { ["pid"]=> NULL } [9]=> array(1) { ["pid"]=> NULL } } }
Output for 5.3.0 - 5.3.29
Notice: Use of undefined constant JSON_PRETTY_PRINT - assumed 'JSON_PRETTY_PRINT' in /in/r6nNK on line 17 Warning: json_encode() expects parameter 2 to be long, string given in /in/r6nNK on line 17 NULL
Output for 5.2.0 - 5.2.17
Notice: Use of undefined constant JSON_PRETTY_PRINT - assumed 'JSON_PRETTY_PRINT' in /in/r6nNK on line 17 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/r6nNK on line 17 NULL
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_encode() in /in/r6nNK on line 17
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_encode() in /in/r6nNK on line 17
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_encode() in /in/r6nNK on line 17
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_encode() in /in/r6nNK on line 17