//Initiate new array to store coords
$latlongs = array();
//Loop through your array
foreach($yourArray as $k=>$v){
// Loop through the partnerlist to extract lat/lon
// Append to your coord array, and preserve the industry key
// So that you know which lat/lons came from where
foreach($v['partnerlist'] as $a){
$latlongs[$k][] = array("latitude"=>$a['latitude'],"longitude"=>$a['longitude'];
}
}
This will preserve the key, so that you can group all your coords together by their original category.
If you dont care about that and purely want just the lat/long, then simply do…
foreach($yourArray as $v){
foreach($v['partnerlist'] as $a){
$latlongs[] = array("latitude"=>$a['latitude'],"longitude"=>$a['longitude'];
}
}
solved looping thru multidimentional array and getting value of keys [closed]