note 90929 added to function.is-array
| From: | Anonymous at osu1 dot php dot net | Date: | Sat, 16 May 2009 21:18:53 +0000 |
| Subject: | note 90929 added to function.is-array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-154678@lists.php.net to get a copy of this message | ||
Using empty() in the previous example posted by Anonymous will result in a "Fatal error:
Can't use function return value in write context". I suggest using count() instead:
<?php
function is_assoc($array) {
return (is_array($array) && 0 !== count(array_diff_key($array,
array_keys(array_keys($array)))));
}
?>
----
Server IP: 69.147.83.197
Probable Submitter: 76.30.145.204
----
Manual Page -- http://www.php.net/manual/en/function.is-array.php
Edit -- https://master.php.net/note/edit/90929
Del: integrated -- https://master.php.net/note/delete/90929/integrated
Del: useless -- https://master.php.net/note/delete/90929/useless
Del: bad code -- https://master.php.net/note/delete/90929/bad+code
Del: spam -- https://master.php.net/note/delete/90929/spam
Del: non-english -- https://master.php.net/note/delete/90929/non-english
Del: in docs -- https://master.php.net/note/delete/90929/in+docs
Del: other reasons-- https://master.php.net/note/delete/90929
Reject -- https://master.php.net/note/reject/90929
Search -- https://master.php.net/manage/user-notes.php