Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php get intersection of arrays

$array1 = [1, 2];
$array2 = [2, 3, 4];
$commonValue = array_intersect($array1, $array2);
//$commonValue = 2
// If you have X number of arrays you can do:
$array1 = [1, 2];
$array2 = [2, 3, 4];
$arrayOfArrays = [$array1, $array2];
$commonValue = array_intersect(...$arrayOfArrays);
Comment

PREVIOUS NEXT
Code Example
Php :: wordpress wpdb 
Php :: phpmyadmin import size limit 
Php :: magento 2 get collection 
Php :: showing database table in php 
Php :: websocket 2006 MySQL server has gone away 
Php :: get current page php 
Php :: memory limit wordpress 
Php :: collection continue in laravel 
Php :: php 6 digit random number 
Php :: laravel force user logout 
Php :: laravel-admin Model does not exists ! 
Php :: php get file type from url 
Php :: run a server php with a specific folder terminal 
Php :: update query wordpress 
Php :: php artisan preset react 
Php :: laravel migration add column after 
Php :: check is array laravel 
Php :: access config variable in codeigniter controller 
Php :: php check weekday of date 
Php :: php déclarer une constante URL 
Php :: get current year php 
Php :: laravel module remove 
Php :: laravel check collection has key 
Php :: laravel make model and controller 
Php :: php find key in array 
Php :: php repeat string 
Php :: acf get user form field 
Php :: laravel where condition on relationship 
Php :: install php 7.4 ubuntu 
Php :: php string replace regex 
ADD CONTENT
Topic
Content
Source link
Name
2+9 =