Re: [PHP] Counting elements in an array

2003-11-19 Thread John Nichel
Jeff McKeon wrote: How would I count the number of elements in an array that had a certain value? In other words, if I have $fruit = array(orange,orange,apple,bananna,orange,apple,pear); How could I get the number of elements from $fruit where the value is "orange"? Thanks, Jeff $temp = array_

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jay Blanchard
[snip] >> $fruit = array(orange,orange,apple,bananna,orange,apple,pear); >> >> How could I get the number of elements from $fruit where the value is >> "orange"? [/snip] >From http://www.php.net/array_keys with additions; $array = array("blue", "red", "green", "blue", "blue"); $countArray = coun

Re: [PHP] Counting elements in an array

2003-11-19 Thread Jason Wong
On Thursday 20 November 2003 00:33, Jeff McKeon wrote: > Jason Wong wrote: > > On Wednesday 19 November 2003 23:24, Jeff McKeon wrote: > >> How would I count the number of elements in an array that had a > >> certain value? > >> > >> In other words, if I have > >> > >> $fruit = array(orange,orange,

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jeff McKeon
Jason Wong wrote: > On Wednesday 19 November 2003 23:24, Jeff McKeon wrote: >> How would I count the number of elements in an array that had a >> certain value? >> >> In other words, if I have >> >> $fruit = array(orange,orange,apple,bananna,orange,apple,pear); >> >> How could I get the number

Re: [PHP] Counting elements in an array

2003-11-19 Thread Jason Wong
On Wednesday 19 November 2003 23:24, Jeff McKeon wrote: > How would I count the number of elements in an array that had a certain > value? > > In other words, if I have > > $fruit = array(orange,orange,apple,bananna,orange,apple,pear); > > How could I get the number of elements from $fruit where th

RE: [PHP] Counting elements in an array

2003-11-19 Thread Jay Blanchard
[snip] How would I count the number of elements in an array that had a certain value? In other words, if I have $fruit = array(orange,orange,apple,bananna,orange,apple,pear); How could I get the number of elements from $fruit where the value is "orange"? [/snip] http://www.php.net/array_keys -

Re: [PHP] Counting elements in an array

2003-11-19 Thread Sophie Mattoug
$i = 0; foreach ($fruit as $k) if ('prange' == $k) $i++; (The result is $i, of course) Jeff McKeon wrote: How would I count the number of elements in an array that had a certain value? In other words, if I have $fruit = array(orange,orange,apple,bananna,orange,apple,pear); How could I get th

[PHP] Counting elements in an array

2003-11-19 Thread Jeff McKeon
How would I count the number of elements in an array that had a certain value? In other words, if I have $fruit = array(orange,orange,apple,bananna,orange,apple,pear); How could I get the number of elements from $fruit where the value is "orange"? Thanks, Jeff -- PHP General Mailing List (htt