3v4l.org

run code in 300+ PHP versions simultaneously
<?php class NonExistant { protected $associativeArray = array( 'one' => 'one', 'two' => 'two', 'three' => 'three', 'four' => 'four', 'five' => 'five', 'six' => 'six', ); protected $numIterations = 1000; public function issetTest() { for ($i = 0; $i < $this->numIterations; $i++) { isset($this->associativeArray['none']); } } public function arrayKeyExistsTest() { for ($i = 0; $i < $this->numIterations; $i++) { array_key_exists('none', $this->associativeArray); } } } $class = new NonExistant(); foreach (array('issetTest', 'arrayKeyExistsTest') as $func) { $time_start = microtime(); $class->$func(); $time_end = microtime(); $time = $time_end - $time_start; echo "Did $func in $time seconds\n"; }

preferences:
34.39 ms | 402 KiB | 5 Q