<HTML ><HEAD ><TITLE >array_intersect_assoc</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_flip" HREF="function.array-flip.html"><LINK REL="NEXT" TITLE="array_intersect" HREF="function.array-intersect.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-flip.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-intersect.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ></TABLE ><HR ALIGN="LEFT" WIDTH="100%"></DIV ><H1 ><A NAME="function.array-intersect-assoc" ></A >array_intersect_assoc</H1 ><DIV CLASS="refnamediv" ><A NAME="AEN4939" ></A ><P > (PHP 4 >= 4.3.0)</P >array_intersect_assoc -- Computes the intersection of arrays with additional index check</DIV ><DIV CLASS="refsect1" ><A NAME="AEN4942" ></A ><H2 >Description</H2 >array <B CLASS="methodname" >array_intersect_assoc</B > ( array array1, array array2 [, array ...])<BR ></BR ><P > <B CLASS="function" >array_intersect_assoc()</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 the keys are used in the comparison unlike in <A HREF="function.array-intersect.html" ><B CLASS="function" >array_intersect()</B ></A >. </P ><P > <TABLE WIDTH="100%" BORDER="0" CELLPADDING="0" CELLSPACING="0" CLASS="EXAMPLE" ><TR ><TD ><DIV CLASS="example" ><A NAME="AEN4961" ></A ><P ><B >Ejemplo 1. <B CLASS="function" >array_intersect_assoc()</B > example</B ></P ><TABLE BORDER="0" BGCOLOR="#E0E0E0" CELLPADDING="5" ><TR ><TD ><PRE CLASS="php" ><?php $array1 = array ("a" => "green", "b" => "brown", "c" => "blue", "red"); $array2 = array ("a" => "green", "yellow", "red"); $result_array = array_intersect_assoc ($array1, $array2); /* $result_array will look like: Array ( [a] => green ) */ ?></PRE ></TD ></TR ></TABLE ></DIV ></TD ></TR ></TABLE > </P ><P > In our example you see that only the pair <TT CLASS="literal" >"a" => "green"</TT > is present in both arrays and thus is returned. The value <TT CLASS="literal" >"red"</TT > is not returned because in <TT CLASS="varname" >$array1</TT > it's key is <TT CLASS="literal" >2</TT > while the key of "red" in <TT CLASS="varname" >$array2</TT > it is <TT CLASS="literal" >1</TT >. </P ><P > The two values from the <TT CLASS="literal" >key => value</TT > pairs are considered equal only if <TT CLASS="literal" >(string) $elem1 === (string) $elem2 </TT >. In otherwords a strict type check is executed so the string representation must be the same. </P ><P > See also <A HREF="function.array-intersect.html" ><B CLASS="function" >array_intersect()</B ></A >, <A HREF="function.array-diff.html" ><B CLASS="function" >array_diff()</B ></A > and <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-flip.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-intersect.html" ACCESSKEY="N" >Siguiente</A ></TD ></TR ><TR ><TD WIDTH="33%" ALIGN="left" VALIGN="top" >array_flip</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_intersect</TD ></TR ></TABLE ></DIV ></BODY ></HTML >