note 43918 added to function.array-count-values
| From: | da at canaan dot co dot il | Date: | Thu, 08 Jul 2004 14:32:25 +0000 |
| Subject: | note 43918 added to function.array-count-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-72881@lists.php.net to get a copy of this message | ||
About checking if an array is empty or got in any of his keys (or all of them) a value.
I just want to correct what "programmer at bardware dot de" wrote, though it was extremly
helpful and smart just had a little typo :)
So i'll take his function and make it more conveint and just correct so whoever you are can
just copy&paste it to check it:
$a[0] = "";
$a[1] = "";
$arrFoo=array_count_values($a);
if( isset($arrFoo[""])) {
if (count($a)==$arrFoo[""])
$allempty = count($a);
}
if($allempty)
echo 'no values';
else
echo 'got values';
Just play with the array and youll see that its working.
Thanks again to "programmer at bardware dot de" :)
----
Manual Page -- http://www.php.net/manual/en/function.array-count-values.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+43918
Delete -- http://master.php.net/manage/user-notes.php?action=delete+43918&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+43918&report=yes
Search -- http://master.php.net/manage/user-notes.php