@ 2015-11-13T11:22:01Z <?php
// string, null, bool, float, largest specified previous index
function isIndexedArray($array) {
return !(bool)count(array_filter(array_keys($array), 'is_string'));
}
var_dump(isIndexedArray('a')); // false
var_dump(isIndexedArray(NULL)); // false
var_dump(isSequentialArray([])); // true/undefined
var_dump(isSequentialArray(['a'])); // true
var_dump(isSequentialArray(['a' => 1])); // false
array(1=>'a',2=>'b')
empty string
['a' => 'a'];
[1 => 'a'];
[1,2,null,4]
var_dump(isSequentialArray(array(0 => 'a', 1 => 'b'))); // true
var_dump(isSequentialArray(array(0 => 'a', 5 => 'b'))); // true
var_dump(isSequentialArray(array('a', 'b', 'c'))); // false
var_dump(isSequentialArray(array("0" => 'a', "1" => 'b', "2" => 'c'))); // false
var_dump(isSequentialArray(array("1" => 'a', "0" => 'b', "2" => 'c'))); // true
var_dump(isSequentialArray(array("a" => 'a', "b" => 'b', "c" => 'c'))); // true
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).
Version System time (s) User time (s) Memory (MiB) 5.6.15 0.007 0.047 18.17 5.6.14 0.007 0.037 18.18 5.6.13 0.003 0.083 18.21 5.6.12 0.013 0.080 20.98 5.6.11 0.007 0.057 20.98 5.6.10 0.007 0.043 20.98 5.6.9 0.013 0.077 21.08 5.6.8 0.000 0.090 20.39 5.5.30 0.007 0.047 18.02 5.5.29 0.003 0.070 18.07 5.5.28 0.010 0.080 20.85 5.5.27 0.017 0.073 20.98 5.5.26 0.013 0.073 20.73 5.5.25 0.007 0.040 20.59 5.5.24 0.043 0.060 20.23
preferences:dark mode live preview
141.35 ms | 1398 KiB | 7 Q