I am putting the data in multiple array in php and trying to access it through key value pair logic but not getting success
Here's the output when I'm printing the array with print_r:
Array (
[0] => Array (
[33] => Coca Cola Products
)
[1] => Array (
[1] => Agricultural products, Food and Beverages
)
)
The code I'musing:
foreach ($data as $key=>$option)
{
echo $key;
}
output required:
33 coca cola products
1 Agricultural products, Food and Beverages
In my for-loop for populating data I'm doing this:
$data[] = array($loop['category_id'] => $loop['category_name']);
Now wanted to get category id and category name
$data[$loop['category_id']) = $loop['category_name'];and just do this in your foreach:echo $key . ' ' . $option;