3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $j = '{"data":{"lan":[{"name":"Primary LAN Eth"},{"ip_address":"192.168.10.2"}]}}'; $jd = json_decode($j); // var_dump($jd); function quote($v) { return '"'.$v.'"'; } function bracket($v) { return '{'.$v.'}'; } // Convert a decoded JSON object back into a JSON string, but ignore arrays for cradlepoint function stringify($v) { $str = ""; switch(gettype($v)) { case 'array': for ($i = 0; $i < count($v); $i++) $str .= ($i == 0 ? '':',').quote($i).':'.stringify($v[$i]); $str = bracket($str); break; case 'object': $c = ''; foreach ($v as $k=>$v) { $str .= $c.quote($k).':'.stringify($v); $c = ','; } $str = bracket($str); break; case 'boolean': $str .= ($v ? 'true' : 'false'); break; case 'integer': case 'double': $str .= ''.$v; break; case 'string': $str .= quote($v); break; case 'NULL': $str .= 'null'; break; default: break; } return $str; } echo stringify($jd); ?>
Output for 5.2.0 - 5.6.28, hhvm-3.10.0 - 3.12.0, 7.0.0 - 7.1.0
{"data":{"lan":{"0":{"name":"Primary LAN Eth"},"1":{"ip_address":"192.168.10.2"}}}}
Output for 5.0.0 - 5.1.6
Fatal error: Call to undefined function json_decode() in /in/2iNYm on line 4
Process exited with code 255.
Output for 4.4.5 - 4.4.9
Fatal error: Call to undefined function: json_decode() in /in/2iNYm on line 4
Process exited with code 255.
Output for 4.3.2 - 4.4.4
Fatal error: Call to undefined function: json_decode() in /in/2iNYm on line 4
Process exited with code 255.
Output for 4.3.0 - 4.3.1
Fatal error: Call to undefined function: json_decode() in /in/2iNYm on line 4