<HTML ><HEAD ><TITLE >array_intersect</TITLE ><META NAME="GENERATOR" CONTENT="Modular DocBook HTML Stylesheet Version 1.7"><LINK REL="HOME" TITLE="Manual de PHP" HREF="index.html"><LINK REL="UP" TITLE="Funciones de matrices" HREF="ref.array.html"><LINK REL="PREVIOUS" TITLE="array_intersect_assoc" HREF="function.array-intersect-assoc.html"><LINK REL="NEXT" TITLE="array_key_exists" HREF="function.array-key-exists.html"><META HTTP-EQUIV="Content-type" CONTENT="text/html; charset=ISO-8859-1"></HEAD ><BODY CLASS="refentry" BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#840084" ALINK="#0000FF" ><DIV CLASS="NAVHEADER" ><TABLE SUMMARY="Header navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TH COLSPAN="3" ALIGN="center" >Manual de PHP</TH ></TR ><TR ><TD WIDTH="10%" ALIGN="left" VALIGN="bottom" ><A HREF="function.array-intersect-assoc.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="80%" ALIGN="center" VALIGN="bottom" ></TD ><TD WIDTH="10%" ALIGN="right" VALIGN="bottom" ><A HREF="function.array-key-exists.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.array-intersect" ></A >array_intersect</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN4980" ></A ><P > (PHP 4 >= 4.0.1)</P >array_intersect -- Computes the intersection of arrays</DIV ><DIV CLASS="refsect1" ><A NAME="AEN4983" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >array_intersect</B > ( array array1, array array2 [, array ...])<BR ></BR ><P > <B CLASS="function" >array_intersect()</B > returns an array containing all the values of <TT CLASS="parameter" ><I >array1</I ></TT > that are present in all the arguments. Note that keys are preserved. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN5001" ></A ><P ><B >Ejemplo 1. <B CLASS="function" >array_intersect()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >$array1 = array ("a" => "green", "red", "blue"); $array2 = array ("b" => "green", "yellow", "red"); $result = array_intersect ($array1, $array2);</PRE ></TD ></TR ></TABLE ><P > This makes <TT CLASS="varname" >$result</TT > have <TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" >Array ( [a] => green [0] => red )</PRE ></TD ></TR ></TABLE > </P ></DIV ></TD ></TR ></TABLE > </P ><DIV CLASS="note" ><BLOCKQUOTE CLASS="note" ><P ><B >Nota: </B > Two elements are considered equal if and only if <TT CLASS="literal" >(string) $elem1 === (string) $elem2</TT >. In words: when the string representation is the same. </P ></BLOCKQUOTE ></DIV ><DIV CLASS="warning" ><P ></P ><TABLE CLASS="warning" BORDER="1" WIDTH="100%" ><TR ><TD ALIGN="CENTER" ><B >Aviso</B ></TD ></TR ><TR ><TD ALIGN="LEFT" ><P > This was broken in PHP 4.0.4! </P ></TD ></TR ></TABLE ></DIV ><P > See also <A HREF="function.array-intersect-assoc.html" ><B CLASS="function" >array_intersect_assoc()</B ></A >, <A HREF="function.array-diff.html" ><B CLASS="function" >array_diff()</B ></A >, <A HREF="function.array-diff-assoc.html" ><B CLASS="function" >array_diff_assoc()</B ></A >. </P ></DIV ><DIV CLASS="NAVFOOTER" ><HR ALIGN="LEFT" WIDTH="100%"><TABLE SUMMARY="Footer navigation table" WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" ><A HREF="function.array-intersect-assoc.html" ACCESSKEY="P" >Anterior</A ></TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="index.html" ACCESSKEY="H" >Inicio</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" ><A HREF="function.array-key-exists.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >array_intersect_assoc</TD ><TD WIDTH="34%" ALIGN="center" VALIGN="top" ><A HREF="ref.array.html" ACCESSKEY="U" >Subir</A ></TD ><TD WIDTH="33%" ALIGN="right" VALIGN="top" >array_key_exists</TD ></TR ></TABLE ></DIV ></BODY ></HTML >