I've this array:
Array
(
[USA] => Array
(
[0] => Array
(
[Name] => Apple
[Item] => Phones and Computers
)
[1] => Array
(
[Name] => McDonalds
[Item] => Food
)
)
[China] => Array
(
[0] => Array
(
[Name] => Lenovo
[Item] => Computers
)
)
)
I would like to loop into it and echo the count of items for each country (USA and China).
So my try was this one:
foreach ($arr as $key => $value) {
echo count($arr[$value]);
echo '<br />';
foreach ($value as $subkey => $subvalue) {
echo $value." -> ".$subvalue['Name']." make ".$subvalue['Item']."<br />";
}
}
echo count($newArr[$value]);justecho count($value);. And you can not echo$valuein the second loop as it is array and not a string