I have a multidimensional Array which looks like this:
Array
(
[0] => Array
(
[id] => 1
[name] => Edeka Blaschek
[description] => Lebensmittelmarkt mit Frischfleischtheke und Bäckerei Büsch
[latitude] => 51.1178
[longitude] => 6.77537
[distance] => 0.18105522823916723
)
[1] => Array
(
[id] => 2
[name] => Autohaus Kopenhagen
[description] => Peugeot Händler
[latitude] => 51.1161
[longitude] => 6.77481
[distance] => 0.33650698548914737
)
[2] => Array
(
[id] => 10
[name] => Hallenbad Nievenheim
[description] => Schwimmbad mit Sauna und Sonnenbänken, sowie kleinem Außenbereich
[latitude] => 51.1211
[longitude] => 6.77857
[distance] => 0.38752806088549746
)
)
now I want to remove the distance key and value completely from all arrays in the array. It should look like this:
Array
(
[0] => Array
(
[id] => 1
[name] => Edeka Blaschek
[description] => Lebensmittelmarkt mit Frischfleischtheke und Bäckerei Büsch
[latitude] => 51.1178
[longitude] => 6.77537
)
[1] => Array
(
[id] => 2
[name] => Autohaus Kopenhagen
[description] => Peugeot Händler
[latitude] => 51.1161
[longitude] => 6.77481
)
[2] => Array
(
[id] => 10
[name] => Hallenbad Nievenheim
[description] => Schwimmbad mit Sauna und Sonnenbänken, sowie kleinem Außenbereich
[latitude] => 51.1211
[longitude] => 6.77857
)
)
I've tried the solutions mentioned here: PHP - unset in a multidimensional array but they didn't worked for me, what I'm doing wrong here? Could be very simple sorry but I'm new in PHP.
EDIT: This is the code I tried:
foreach(array_keys($tempArray) as $key) {
unset($tempArray[$key][5]);
}
And this:
foreach($tempArray as $key=>$val){
unset($val[5]);
}
$tempArray is the array that I want to change.