Hello.
May i have an idea to solve this question?
Parameter: An array of strings
Return value: A list of three strings that occur most frequently in the parameter array
I need to use sorting?
Thanks
array(occur most frequently)
Moderator: General Moderators
try
Code: Select all
<?php
$arr = array(
'z', 'b', 'l', 'd',
'a', 'x', 'c', 'd',
'a', 'y', 'z', 'd',
'x', 'b', 'c', 'l',
'a', 'b', 'c', 'l',
'a', 'b', 'c', 'l',
'a', 'h', 'g', 'd',
'a', 'b', 'c', 'd',
'a', 't', 'c', 'i');
$c = array_count_values($arr);
arsort($c);
print_r($c);with a for-loop, see http://de3.php.net/for
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
There's already a thread with the very same subject by you. Locked.
[url=http://forums.devnetwork.net/viewtopic.php?t=30037]Forum Rules[/url] Section 1.1 wrote:3. Do not make multiple, identical posts. This is viewed as spam and will be deleted.