Answers for "php keep both in 2 array"

PHP
2

php get intersection of two 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);
Posted by: Guest on May-30-2020
5

php combine arrays

$output = array_merge($array1, $array2);
Posted by: Guest on June-03-2020

Code answers related to "php keep both in 2 array"

Browse Popular Code Answers by Language