3v4l.org

run code in 300+ PHP versions simultaneously
<?php // Everything is associative array in PHP. Ideal question to ask is if it is sequential // Secondly, going through entire list of items in array is unnecessary function isSequentialArray($array) { return !(bool)count(array_filter(array_keys($array), 'is_string')); } var_dump(isSequentialArray([])); // true/undefined var_dump(isSequentialArray(['a'])); // false var_dump(isAssoc([])); // undefined 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
Output for git.master, git.master_jit, rfc.property-hooks
bool(true) bool(true) Fatal error: Uncaught Error: Call to undefined function isAssoc() in /in/0aHns:13 Stack trace: #0 {main} thrown in /in/0aHns on line 13
Process exited with code 255.

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
30.99 ms | 401 KiB | 8 Q