3v4l.org

run code in 300+ PHP versions simultaneously
<?php // one-dimensional arrays $array = array_fill(0,50000,'tommy is the best!'); $arraykeyexists_result = array(); $start = microtime(true); for ($i = 0; $i < 100000; $i++) { if (array_key_exists($i,$array)) { $arraykeyexists_result[] = 1; } else { $arraykeyexists_result[] = 0; } } $arrtime = round(microtime(true)-$start,3); $start = microtime(true); for ($i = 0; $i < 100000; $i++) { if (isset($array[$i])) { $arraykeyexists_result[] = 1; } else { $arraykeyexists_result[] = 0; } } $istime = round(microtime(true)-$start,3); $totaltime = $arrtime+$istime; $arrpercentage = round(100*$arrtime/$totaltime,3); $ispercentage = round(100*$istime/$totaltime,3); echo "array_key_exists(): $arrtime [$arrpercentage%] seconds\n"; echo "isset(): $istime [$ispercentage%] seconds\n";

preferences:
44.61 ms | 402 KiB | 5 Q