“Php array_intersect” Código de respuesta

array_intersect php

<?php
$a1 = array("a"=>"red", "b"=>"green", "c"=>"blue", "d"=>"yellow");
$a2 = array("e"=>"red", "f"=>"green", "g"=>"blue");

$result = array_intersect($a1, $a2);
print_r($result); //Array ( [a] => red [b] => green [c] => blue )
Lokesh003Coding

PHP obtiene la intersección de dos matrices

$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);
Unsightly Unicorn

Php array_intersect

PHP function array_intersect(array $array1, array $array2, array ...$_) int[]
-----------------------------------------------------------------------------
Computes the intersection of arrays
  
Parameters:
array--$array1--The array with main values to check.
array--$array2--An array to compare values against.
array--...$_--[optional]
Returns: an array containing all of the values in array1 whose values exist in all of the parameters.
Imtiaz Epu

Respuestas similares a “Php array_intersect”

Preguntas similares a “Php array_intersect”

Más respuestas relacionadas con “Php array_intersect” en PHP

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código