Good day, Im trying to Get the most repeated inside a foreach
loop on php. Each array is a cycle of the loop. I need to get the id
and name
of the most repeated item, in this example is jake.
This is the loop:
foreach ($json[$key]['data'] as $user){
var_dump($user);
}
and the output is:
array(2) {
["id"]=>
string(4) "7032"
["name"]=>
string(4) "Jake"
}
array(2) {
["id"]=>
string(4) "1021"
["name"]=>
string(3) "Ana"
}
array(2) {
["id"]=>
string(4) "2058"
["name"]=>
string(4) "John"
}
array(2) {
["id"]=>
string(4) "7032"
["name"]=>
string(4) "Jake"
}
I need the output to be:
$repeated = array(2) {
["id"]=>
string(4) "7032"
["name"]=>
string(4) "Jake"
}
Thanks in advance for all your answers.