note 88489 added to function.is-array
| From: | mike at van dot lammeren dot net | Date: | Mon, 26 Jan 2009 20:51:36 +0000 |
| Subject: | note 88489 added to function.is-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-149802@lists.php.net to get a copy of this message | ||
I started this thread in 2003, when I posted as 'mike-php'. There have been a lot of
suggestions of questionable quality since then. You may be interested to know that all this time
later, I still use the 'vhermecz' version of my original algorithm.
/**
* Note:
* - empty arrays are identified as associative arrays.
* - associative arrays whose keys are coincidentally the same as a non-associative array
* will be identified as NOT associative
* @param array $given
* @return boolean true if the given value is an associative array, false otherwise
*/
function is_assoc_array($given)
{
return is_array($given) and array_keys($given) !== range(0, sizeof($given)-1);
}
----
Server IP: 216.235.13.26
Probable Submitter: 216.16.241.202
----
Manual Page -- http://www.php.net/manual/en/function.is-array.php
Edit -- https://master.php.net/note/edit/88489
Del: integrated -- https://master.php.net/note/delete/88489/integrated
Del: useless -- https://master.php.net/note/delete/88489/useless
Del: bad code -- https://master.php.net/note/delete/88489/bad+code
Del: spam -- https://master.php.net/note/delete/88489/spam
Del: non-english -- https://master.php.net/note/delete/88489/non-english
Del: in docs -- https://master.php.net/note/delete/88489/in+docs
Del: other reasons-- https://master.php.net/note/delete/88489
Reject -- https://master.php.net/note/reject/88489
Search -- https://master.php.net/manage/user-notes.php