Skip to content

Instantly share code, notes, and snippets.

@PhouvanhKCSV
Forked from twysto/array_multi_unique.php
Created July 21, 2017 07:57
Show Gist options
  • Save PhouvanhKCSV/8143b7ee36be53e33f790491016ab232 to your computer and use it in GitHub Desktop.
Save PhouvanhKCSV/8143b7ee36be53e33f790491016ab232 to your computer and use it in GitHub Desktop.
[PHP] array_unique in a multi-dimensional array
<?php
function array_multi_unique($array) {
$tmp_ComparisonArray = $final_Array = Array();
foreach($array as $key => $value) {
if(!in_array($value[0], $tmp_ComparisonArray)) {
$tmp_ComparisonArray[] = $value[0];
$final_Array[] = $value;
}
}
return $final_Array;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment