3v4l.org

run code in 300+ PHP versions simultaneously
<?php // test one.. // start time $st = microtime(); function arr1(){ $arr1 = array(); $arr2 = array(); $arr3 = array(); $arr1['key1'] = 'val1'; $arr2['key1'] = 'val1'; $arr3['key1'] = 'val1'; return array($arr1, $arr2, $arr3); } $i = 1000; while($i--){ $poo = arr1(); } echo "Method 1: created 1000 arrays in " . (microtime() - $st) . " microseconds...\n"; // test two.. // start time $st = microtime(); function arr2(){ $arr1 = array(); $arr1['arr1']['key1'] = 'val1'; $arr1['arr2']['key1'] = 'val1'; $arr1['arr3']['key1'] = 'val1'; return array($arr1); } $i = 1000; while($i--){ $poo = arr2(); } echo "Method 2: created 1000 arrays in " . (microtime() - $st) . " microseconds...\n";

preferences:
32.08 ms | 404 KiB | 5 Q