Created
May 20, 2019 05:03
-
-
Save Guley/ffbf7e99c906344697f17c2473950d0e to your computer and use it in GitHub Desktop.
Unique multidimensional array in php
This file contains hidden or 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 | |
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