Source Code:
(back to article)
<?php $array = ['a' => 1, 'b' => 2, 'c' => 3]; $associative = false; foreach ($array as $key => $value) { if (!is_int($key)) { $associative = true; break; } } if ($associative) { // associative array echo 'associative array'; } else { // sequential array echo 'sequential array'; }
Result:
Report an issue