note 94920 added to function.is-array
| From: | PhilLello at osu1 dot php dot net | Date: | Wed, 02 Dec 2009 23:45:28 +0000 |
| Subject: | note 94920 added to function.is-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-163509@lists.php.net to get a copy of this message | ||
Another is_assoc():
function is_assoc($array) {
return is_int(array_keys($array)[0]);
}
Note: Haven't tested this exact function, but have used is_int inside a foreach. It is
reasonable to assume that if a user is using integers as keys, then it isn't an associative
array. Could also loop through all keys to make sure, but that seems redundant.
----
Server IP: 69.147.83.197
Probable Submitter: 90.214.216.211
----
Manual Page -- http://www.php.net/manual/en/function.is-array.php
Edit -- https://master.php.net/note/edit/94920
Del: integrated -- https://master.php.net/note/delete/94920/integrated
Del: useless -- https://master.php.net/note/delete/94920/useless
Del: bad code -- https://master.php.net/note/delete/94920/bad+code
Del: spam -- https://master.php.net/note/delete/94920/spam
Del: non-english -- https://master.php.net/note/delete/94920/non-english
Del: in docs -- https://master.php.net/note/delete/94920/in+docs
Del: other reasons-- https://master.php.net/note/delete/94920
Reject -- https://master.php.net/note/reject/94920
Search -- https://master.php.net/manage/user-notes.php