I am using foreach loop to assign values to an array.
$route_selection;
foreach ($routes as $route) {
$from_state = $route->fromState->name;
$to_state = $route->toState->name;
$from_country = $route->fromCountry->name;
$to_country = $route->tocountry->name;
$route_selection[] = [$route->hash_id => 'From: '.$from_state.' ('.$from_country.') To: '.$to_state.' ('.$to_country.')'];
}
Sure enough, it will have a result to something like this:

But I want the result to be something like this:

How can I possibly do that in PHP?