note 85924 modified in function.array-values by danbrown
| From: | danbrown@php.net | Date: | Wed, 24 Sep 2008 19:38:55 +0000 |
| Subject: | note 85924 modified in function.array-values by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-144685@lists.php.net to get a copy of this message | ||
If you are looking for a way to count the total number of times a specific value appears in array,
use this function:
<?php
function array_value_count ($match, $array)
{
$count = 0;
foreach ($array as $key => $value)
{
if ($value == $match)
{
$count++;
}
}
return $count;
}
?>
This should really be a native function of PHP.
--was--
If you are looking for a way to count the total number of times a specific value appears in array,
use this function:
function array_value_count ($match, $array)
{
$count = 0;
foreach ($array as $key => $value)
{
if ($value == $match)
{
$count++;
}
}
return $count;
}
This should really be a native function of PHP.
http://php.net/manual/en/function.array-values.php