How would I show this array Array ( [hGWMr8] => 7 [pQhe5H] => 1 ) Code (markup): Like this hGWMr8 = 7 pQhe5H = 1 Thanks in advanced.
If I use the following $select = mysql_fetch_object(mysql_query("SELECT * FROM websites WHERE id = '2'")); $who = explode(", ", $select->readby); $count = count($who); echo print_r(array_count_values($who)); PHP: I get Array ( [hGWMr8] => 7 [pQhe5H] => 1 ) Code (markup): How do I change that to this hGWMr8 = 7 pQhe5H = 1
I dont know whether i have understood correctly or not. This example may help you.. $fruits = array("d"=>"lemon", "a"=>"orange", "b"=>"banana", "c"=>"apple"); krsort($fruits); foreach ($fruits as $key => $val) { echo "$key = $val\n"; } I got it from php.net
For ur case u can surely use the example. instead of $fruits you can give ur $who array and get the ouptut. Still i dont know why u want to get this for an array, which is got by explode function... by default the explode funtion will return the index as 0,1,2,... or did set any key for the array previously?
Worked a treat thanks I did this <? $select = mysql_fetch_object(mysql_query("SELECT * FROM websites WHERE id = '2'")); $who = explode(", ", $select->readby); $thearray = array_count_values($who); krsort($thearray); foreach ($thearray as $key => $val) { echo "$key = $val\n"; } ?> PHP:
Sorry i didnt noticed that you have used array_count_values in ur program so only i arised that qusetion... Any how u got that... so happy...