I have two strings that contain information about countries and cities
$city = "Munich, Berlin, London, Paris, Vienna, Milano, Rome";
$country = "Germany, Germany, UK, France, Austria, Italy, Italy";
$city = explode(', ', $city);
$country = explode(', ', $country);
I know how to foreach trough single array. In the example below I am getting trough country array and add the $value
foreach($country as $value)
{
$data[] = array (
"text" => $value,
"entities" => [
array (
"entity" => $city
)
]
);}
But cannot figure out how to also incorporate the $city array and get the appropriete value. For example, the expected result is
foreach($country as $value)
{
$data[] = array (
"text" => France,
"entities" => [
array (
"entity" => Paris
)
]
);}