Re: SV: [PHP] Array help needed

From: Date: Thu, 18 Jan 2001 12:38:50 +0000
Subject: Re: SV: [PHP] Array help needed
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-35334@lists.php.net to get a copy of this message
Thanks. Getting this error. Cannot increment/decrement overloaded objects nor string offsets. Any idea? Chris At 05:54 AM 1/18/01, Knut Sætre wrote:
Try this: $array = array(1,2,3,4,5,3,3,1); foreach(array_values($array) as $s) { $count[$s]++; } foreach(array_keys($count) as $s) { echo "Number: " . $s. " count: " . $count[$s] . "<Br>"; } -----Opprinnelig melding----- Fra: CDitty [mailto:mail@redhotsweeps.com] Sendt: 18. januar 2001 12:40 Til: php-general@lists.php.net Emne: [PHP] Array help needed Hello all, I have 6 numbers that are in an array. I need to know how many times each number shows up in that array. ex.... Numbers: 1,3,5,1,4,1 Output needed: (Not necessarily like this) 1 3 3 1 5 1 4 1 Can anyone help me with this? I looked in the manual, but couldn't find anything that was quite what I needed. I have tried sorting then array_count_values, but ended up with a result like this. Some results have counts, some don't. 1 2 1 4 1 4 4 3 5 1 Thanks Chris -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net


« previous php.general (#35334) next »