note 35097 added to function.array-count-values
| From: | programmer at bardware dot de | Date: | Tue, 19 Aug 2003 16:24:25 +0000 |
| Subject: | note 35097 added to function.array-count-values | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-54702@lists.php.net to get a copy of this message | ||
array_count_values returns the number of keys if empty(value). I expected array_count_values to
return 0 for empty values.
Array looks like:
Array
(
[459] =>
[543] =>
[8959] =>
[11273] =>
)
array_count_values returns:
Array
(
[] => 4
)
count(array_count_values(array)) does thus not report there are no values (other than empty) in the
array.
I therefore check:
$arrFoo=array_count_values($arrBar);
if(isset($arrFoo[""]) $allempty=count($arrBar)==$arrFoo[""];
if(!$allempty)
//process the array
else
//no need to work on the array
----
Manual Page -- http://www.php.net/manual/en/function.array-count-values.php
Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+35097
Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+35097&report=yes
Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+35097&report=yes