method isAssoc documentation in bbn\X
Checks if the given array is associative.
Example
\bbn\\X::isAssoc(['id' => 0, 'name' => 'Allison']);
\bbn\\X::isAssoc(['Allison', 'John', 'Bert']);
\bbn\\X::isAssoc([0 => "Allison", 1 => "John", 2 => "Bert"]);
\bbn\\X::isAssoc([0 => "Allison", 1 => "John", 3 => "Bert"]);
// boolean true
// boolean false
// boolean false
// boolean true
function(array $r)
{
$keys = array_keys($r);
$c = \count($keys);
for ($i = 0; $i < $c; $i++) {
if ($keys[$i] !== $i) {
return 1;
}
}
return false;
}
Checks if the given array is associative. BBN is a suite of PHP and JS libraries and VueJS components - all open-source! bbn.io, build applications, the quick way
This website uses cookies to ensure you get the best experience on our website.
© 2011-2025
BBN Solutions