get unique array from multidimentional array by value in php

<?php
    function super_unique($array,$key)
    {
       $temp_array = [];
       foreach ($array as &$v) {
           if (!isset($temp_array[$v[$key]]))
           $temp_array[$v[$key]] =& $v;
       }
       $array = array_values($temp_array);
       return $array;

    }


$arr="";
$arr[0]['id']=0;
$arr[0]['titel']="ABC";
$arr[1]['id']=1;
$arr[1]['titel']="DEF";
$arr[2]['id']=2;
$arr[2]['titel']="ABC";
$arr[3]['id']=3;
$arr[3]['titel']="XYZ";

echo "<pre>";
print_r($arr);
echo "unique*********************<br/>";
print_r(super_unique($arr,'titel'));

?>

3.71
7

                                    $uniquePids = array_unique(array_map(function ($i) { return $i['pid']; }, $holder));

3.71 (7 Votes)
0
Are there any code examples left?
Create a Free Account
Unlock the power of data and AI by diving into Python, ChatGPT, SQL, Power BI, and beyond.
Sign up
Develop soft skills on BrainApps
Complete the IQ Test
Relative searches
unique value from two array in php some array keep two times in array_unique php array_unique for multidimensional array in php php unique array multidimensional multi key php array unique multidimensional by value php get unique values from 1d array multi array unique php php get unique values from 2d array get unique values from 2 arrays php array unique on array column which is an array php php get unique values from two arrays php get unique values from two array get unique items from 2 array php php unique 2 arrays with same keys php two array get unique array unique multidimensional array php unique multidimensional array php two array get only unique values php unique value in two array php multi array to single unique array php nested array unique values php php array multidimensional to unique array unique multidimensional php php array unique multidimensional how to find unique in two array in php get unique values from two array php php array unique multidimensional by key Array_unique multidimensional PHP array_unique in multidimensional array php php array_unique for multidimensional array unique value by key php multidimensional array php array_unique multidimensional how to do array unique in multi dimension array in php array_unique array column multidimensional array php array_unique multidimensional array php filter unique multidimensional array php php get unique values from multidimensional array get unique array from multidimentional array by value in php
Made with love
This website uses cookies to make IQCode work for you. By using this site, you agree to our cookie policy

Welcome Back!

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign in
Recover lost password
Or log in with

Create a Free Account

Sign up to unlock all of IQCode features:
  • Test your skills and track progress
  • Engage in comprehensive interactive courses
  • Commit to daily skill-enhancing challenges
  • Solve practical, real-world issues
  • Share your insights and learnings
Create an account
Sign up
Or sign up with
By signing up, you agree to the Terms and Conditions and Privacy Policy. You also agree to receive product-related marketing emails from IQCode, which you can unsubscribe from at any time.
Creating a new code example
Code snippet title
Source