RE: array_count_values Problem

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi, 

  Thanks for the replies. 

  Turns out that I can assign a variable $array_count = array_count_values($friend_from), and I accessed the individual values by doing 

for ($i=0;$i<$total_num;$i++) {

    $friend_location = $friend_from[$i];  
    $count_friend = $array_count[$friend_location];      
    echo $count_friend . "\n";    
}

Thanks again. 

Alice

> Date: Tue, 12 Jan 2010 13:17:57 -0300
> Subject: Re:  array_count_values Problem
> From: tapicer@xxxxxxxxx
> To: ajwei@xxxxxxxxxxxxx
> CC: php-general@xxxxxxxxxxxxx
> 
> Hi,
> 
> The function array_count_values returns an array
> (http://php.net/array_count_values). So you are using it the wrong
> way, you should assign the return value to a variable and then access
> some index.
> 
> Regards,
> 
> Jonathan
> 
> On Tue, Jan 12, 2010 at 11:09 AM, Alice Wei <ajwei@xxxxxxxxxxxxx> wrote:
> >
> > Hi,
> >
> >  I have a code in the following, after investigating more closely on how to use array_count_values():
> >
> >  //Calculate the number of elements in array
> > $total_num = count($friend_from);
> > $total_num2 = count(array_unique($friend_from));
> > for ($i=0;$i<=$total_num2;$i++) echo $friend_from[$i] . " " . array_count_values($friend_from[$i]) . "\n";
> >
> >  Neither of these two numbers, $total_num and $total_num2 are 0, but I only get something like this:
> >
> > Monroe, IN
> > Cherokee, OK
> > Cherokee, OK
> > Cleveland, OK
> > Greer, OK
> >  How come that I cannot get it to print out the individual array_count_values? Have I missed something here?
> >  Thanks for your help.
> >
> >
> > _________________________________________________________________
> > Hotmail: Trusted email with powerful SPAM protection.
> > http://clk.atdmt.com/GBL/go/196390707/direct/01/
 		 	   		  
_________________________________________________________________
Hotmail: Powerful Free email with security by Microsoft.
http://clk.atdmt.com/GBL/go/196390710/direct/01/

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux