Search
 
SCRIPT & CODE EXAMPLE
 

PHP

get unique array from multidimentional array by value in php

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

php unique associative array by value

<?php
    function uniquAsoc($array,$key){
        $resArray=[];
        foreach($array as $val){
          if(empty($resArray)){
            array_push($resArray,$val);
          }else{
            $value=array_column($resArray,$key);
            if(!in_array($val[$key],$value)){
                array_push($resArray,$val);
              }
          }          
        }
        
        return $resArray;
    }
$array=[['phone'=>123,'id'=>1],['phone'=>748,'id'=>1],['phone'=>958,'id'=>3]];
print_r(uniquAsoc($array,'id')); 
/*
Array
(
    [0] => Array
        (
            [phone] => 123
            [id] => 1
        )

    [1] => Array
        (
            [phone] => 958
            [id] => 3
        )

)
  */
?>
Comment

PREVIOUS NEXT
Code Example
Php :: how to upload two files on same form different path in codeigniter 
Php :: laravel hash password check 
Php :: unique key value array php 
Php :: remove last comma from string php foreach 
Php :: convertir datetime a string en php 
Php :: laravel cors enable 
Php :: Remove revisions from Wordpress pages 
Php :: using php to add numbers in html form 
Php :: h:i:s explode in php by ":" 
Php :: get data from 2 table in response laravel 
Php :: Encrypt in PHP openssl and decrypt in javascript CryptoJS 
Php :: sass mix laravel 
Php :: php get 
Php :: isempty php 
Php :: file_get_content 
Php :: array to string conversion php 
Php :: protected gaurded in laravel 
Php :: phpexcel set row height 
Php :: laravel search multiple tables 
Php :: url segment in laravel 
Php :: wordpress autoload composer 
Php :: Show all laravel valet folders 
Php :: php random filename generator 
Php :: run laravel seeder 
Php :: wordpress change post format 
Php :: array push in php 
Php :: html in php function 
Php :: php variable as javascript function parameter in echo 
Php :: pdo error message 
Php :: count column eloquent laravel 
ADD CONTENT
Topic
Content
Source link
Name
7+6 =