Last active
October 17, 2019 14:21
-
-
Save eslavon/43ba0f6a4eed6e864d1d2848f52e1545 to your computer and use it in GitHub Desktop.
Удаление элемента из многомерного массива
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$ids = array_column($array, "address"); | |
$ids = array_unique($ids); | |
$result_array = array_filter( | |
$array, | |
function ($key, $value) use ($ids) { | |
return in_array($value, array_keys($ids)); | |
}, | |
ARRAY_FILTER_USE_BOTH | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
array(10) { | |
[0]=> array(4) { | |
["country"]=> string(12) "Россия" | |
["address"]=> string(36) "Ивановская область" | |
["longitude"]=> float(40.97374) | |
["latitude"]=> float(56.998444) | |
} | |
[1]=> array(4) { | |
["country"]=> string(16) "Беларусь" | |
["address"]=> string(34) "Брестская область" | |
["longitude"]=> float(25.531807) | |
["latitude"]=> float(52.142063) | |
} | |
[2]=> array(4) { | |
["country"]=> string(12) "Россия" | |
["address"]=> string(36) "Московская область" | |
["longitude"]=> float(39.227577) | |
["latitude"]=> float(55.379974) | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
array(10) { | |
[0]=> array(4) { | |
["country"]=> string(12) "Россия" | |
["address"]=> string(36) "Ивановская область" | |
["longitude"]=> float(40.97374) | |
["latitude"]=> float(56.998444) | |
} | |
[1]=> array(4) { | |
["country"]=> string(16) "Беларусь" | |
["address"]=> string(34) "Брестская область" | |
["longitude"]=> float(25.531807) | |
["latitude"]=> float(52.142063) | |
} | |
[2]=> array(4) { | |
["country"]=> string(12) "Россия" | |
["address"]=> string(36) "Ивановская область" | |
["longitude"]=> float(40.980137) | |
["latitude"]=> float(57.018) | |
} | |
[3]=> array(4) { | |
["country"]=> string(12) "Россия" | |
["address"]=> string(36) "Московская область" | |
["longitude"]=> float(39.227577) | |
["latitude"]=> float(55.379974) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment