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_encode", $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.4, 8.3.6
Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 { "success": 1, "products": [ { "pid": "\u00c3\u0082\u00c2\u00a6" }, { "pid": "'\u00c3\u0082\u00c2\u00a8" }, { "pid": "'?" }, { "pid": "'\u00c3\u0082\u00c2\u00b4" }, { "pid": "'\u00c3\u0082\u00c2\u00b8" }, { "pid": "'\u00c3\u0083\u00e2\u0082\u00ac" }, { "pid": "'\u00c3\u0083\u00c2\u0081" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009a" }, { "pid": "'\u00c3\u0083\u00c6\u0092" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009e" } ] }array(2) { ["success"]=> int(1) ["products"]=> array(10) { [0]=> array(1) { ["pid"]=> string(8) "¦" } [1]=> array(1) { ["pid"]=> string(9) "'¨" } [2]=> array(1) { ["pid"]=> string(2) "'?" } [3]=> array(1) { ["pid"]=> string(9) "'´" } [4]=> array(1) { ["pid"]=> string(9) "'¸" } [5]=> array(1) { ["pid"]=> string(11) "'À" } [6]=> array(1) { ["pid"]=> string(9) "'Á" } [7]=> array(1) { ["pid"]=> string(11) "'Â" } [8]=> array(1) { ["pid"]=> string(9) "'Ã" } [9]=> array(1) { ["pid"]=> string(11) "'Ä" } } }
Output for 8.3.5
Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 Deprecated: Function utf8_encode() is deprecated in /in/qnvpe on line 9 { "success": 1, "products": [ { "pid": "\u00c3\u0082\u00c2\u00a6" }, { "pid": "'\u00c3\u0082\u00c2\u00a8" }, { "pid": "'?" }, { "pid": "'\u00c3\u0082\u00c2\u00b4" }, { "pid": "'\u00c3\u0082\u00c2\u00b8" }, { "pid": "'\u00c3\u0083\u00e2\u0082\u00ac" }, { "pid": "'\u00c3\u0083\u00c2\u0081" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009a" }, { "pid": "'\u00c3\u0083\u00c6\u0092" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009e" } ] }array(2) { ["success"]=> int(1) ["products"]=> array(10) { [0]=> array(1) { ["pid"]=> string(8) "¦" } [1]=> array(1) { ["pid"]=> string(9) "'¨" } [2]=> array(1) { ["pid"]=> string(2) "'?" } [3]=> array(1) { ["pid"]=> string(9) "'´" } [4]=> array(1) { ["pid"]=> string(9) "'¸" } [5]=> array(1) { ["pid"]=> string(11) "'À" } [6]=> array(1) { ["pid"]=> string(9) "'Á" } [7]=> array(1) { ["pid"]=> string(11) "'Â" } [8]=> array(1) { ["pid"]=> string(9) "'Ã" } [9]=> array(1) { ["pid"]=> string(11) "'Ä" } } }
Output for 5.4.0 - 5.4.45, 5.5.0 - 5.5.38, 5.6.0 - 5.6.38, 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
{ "success": 1, "products": [ { "pid": "\u00c3\u0082\u00c2\u00a6" }, { "pid": "'\u00c3\u0082\u00c2\u00a8" }, { "pid": "'?" }, { "pid": "'\u00c3\u0082\u00c2\u00b4" }, { "pid": "'\u00c3\u0082\u00c2\u00b8" }, { "pid": "'\u00c3\u0083\u00e2\u0082\u00ac" }, { "pid": "'\u00c3\u0083\u00c2\u0081" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009a" }, { "pid": "'\u00c3\u0083\u00c6\u0092" }, { "pid": "'\u00c3\u0083\u00e2\u0080\u009e" } ] }array(2) { ["success"]=> int(1) ["products"]=> array(10) { [0]=> array(1) { ["pid"]=> string(8) "¦" } [1]=> array(1) { ["pid"]=> string(9) "'¨" } [2]=> array(1) { ["pid"]=> string(2) "'?" } [3]=> array(1) { ["pid"]=> string(9) "'´" } [4]=> array(1) { ["pid"]=> string(9) "'¸" } [5]=> array(1) { ["pid"]=> string(11) "'À" } [6]=> array(1) { ["pid"]=> string(9) "'Á" } [7]=> array(1) { ["pid"]=> string(11) "'Â" } [8]=> array(1) { ["pid"]=> string(9) "'Ã" } [9]=> array(1) { ["pid"]=> string(11) "'Ä" } } }
Output for 5.3.0 - 5.3.29
Notice: Use of undefined constant JSON_PRETTY_PRINT - assumed 'JSON_PRETTY_PRINT' in /in/qnvpe on line 17 Warning: json_encode() expects parameter 2 to be long, string given in /in/qnvpe 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/qnvpe on line 17 Warning: json_encode() expects exactly 1 parameter, 2 given in /in/qnvpe 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/qnvpe 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/qnvpe 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/qnvpe 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/qnvpe on line 17

preferences:
333.85 ms | 401 KiB | 451 Q