Answers for "get same keys from 2 array in php"

PHP
1

php multidimensional array get all values by key

$ids = array_column($users, 'id');
Posted by: Guest on May-04-2021
0

php get keys of duplicate values in array

<?php
/** 
	Examples of these functions:
	array_unique, 
    array_diff_assoc, 
    array_diff, 
    array_keys, 
    array_intersect 
    
    Examle with an array: 
*/
$array = array('a', 'a', 'b', 'c', 'd');

// Unique values
$unique = array_unique($array);

// Duplicates
$duplicates = array_diff_assoc($array, $unique);

// Unique values
$result = array_diff($unique, $duplicates);

// Get the unique keys
$unique_keys = array_keys($result);

// Get duplicate keys
$duplicate_keys = array_keys(array_intersect($array, $duplicates));
Posted by: Guest on October-28-2020

Code answers related to "get same keys from 2 array in php"

Browse Popular Code Answers by Language