RE: [PHP] Access Array Values?

From: Date: Sun, 24 Feb 2002 22:43:05 +0000
Subject: RE: [PHP] Access Array Values?
Groups: php.general 
Request: Send a blank email to php-general+get-86018@lists.php.net to get a copy of this message
foreach (array_count_values ($names) as $name=>$count) ---------------------------------------------^^ -----Original Message----- From: jtjohnston [mailto:taylorjo@collegesherbrooke.qc.ca] Sent: Monday, February 25, 2002 9:34 AM To: php-general@lists.php.net Subject: Re: [PHP] Access Array Values? I knew there was areason why I stopped Perling :) THANKS! How do I disassemble its values? How would I foreach? Something like this? foreach (array_count_values ($names) as $name and $count) <-?????????? { echo"<a href=\"search.php?input=".$name."\">".$name."</a> (".$count.")<br>`; } <a href="search.php?input=bill">bill</a> (3)<br> <a href="search.php?input=john">john</a> (3)<br> <a href="search.php?input=mary">mary</a> (4)<br> http://www.php.net/manual/en/function.array-count-values.php talks about how it counts. But how do I access each separate value? John ----------snip----------- $names = array ("john", "mary", "bill", "mary", "bill", "mary", "bill", "john", "bill", "john"); echo"<pre>"; print_r($names); echo"</pre>"; echo"<hr><pre>"; print_r(array_count_values ($names)); echo"</pre>"; -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

« previous php.general (#86018) next »