Created
December 1, 2022 05:11
-
-
Save AceAce2025/1299d1a7132a106f8bd6c76e59a1dad6 to your computer and use it in GitHub Desktop.
Revisions
-
AceAce2025 created this gist
Dec 1, 2022 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ <?php // https://www.php.net/manual/en/function.array-unique.php#116302 $details = array( 0 => array("id"=>"1", "name"=>"Mike", "num"=>"9876543210"), 1 => array("id"=>"2", "name"=>"Carissa", "num"=>"08548596258"), 2 => array("id"=>"1", "name"=>"Mathew", "num"=>"784581254"), ); $details = array_unique_multidimesional($details,'id'); function array_unique_multidimesional($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; }