3v4l.org

run code in 300+ PHP versions simultaneously
<?php $array=array("number"=>"3","string"=>"abc","null"=>null); $ncache=array(); $scache=array(); foreach(range(1,10000) as $it) { $ncache[]=$array; $scache[]=$array; } function ncompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=null; } function scompress(&$v) { if(is_numeric($v)) $v=floatval($v); elseif(is_string($v)) $v=trim($v); elseif(is_null($v)) $v=""; } array_walk_recursive($ncache,"ncompress"); array_walk_recursive($scache,"scompress"); echo "Length of null : ".strlen(json_encode($ncache).'('.strlen(gzdeflate(json_encode($ncache))).')'); echo "\n"; echo "Length of string: ".strlen(json_encode($scache).'('.strlen(gzdeflate(json_encode($scache))).')');

preferences:
44.15 ms | 402 KiB | 5 Q