3v4l.org

run code in 300+ PHP versions simultaneously
<?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));
Output for 8.2.0 - 8.2.18, 8.3.0 - 8.3.6
Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 Deprecated: Function utf8_decode() is deprecated in /in/r6nNK on line 9 NULL
Output for 5.5.0 - 5.5.38, 5.6.0 - 5.6.40, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28
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.0.5, 5.1.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.3.11, 4.4.0 - 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

preferences:
326.18 ms | 401 KiB | 459 Q