Skip to content

Instantly share code, notes, and snippets.

@Guley
Created May 20, 2019 05:03
Show Gist options
  • Save Guley/ffbf7e99c906344697f17c2473950d0e to your computer and use it in GitHub Desktop.
Save Guley/ffbf7e99c906344697f17c2473950d0e to your computer and use it in GitHub Desktop.
Unique multidimensional array in php
<?php
function unique_multidim_array($array, $key) {
$temp_array = array();
$i = 0;
$key_array = array();
foreach($array as $val) {
if (!in_array($val[$key], $key_array)) {
$key_array[$i] = $val[$key];
$temp_array[$i] = $val;
}
$i++;
}
return $temp_array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment