Sophie

Sophie

distrib > Mandriva > 9.1 > ppc > by-pkgid > a34ed6838d4b29d38abd504392a4a797 > files > 80

php-manual-es-4.3.0-2mdk.noarch.rpm

<HTML
><HEAD
><TITLE
>array_diff_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_count_values"
HREF="function.array-count-values.html"><LINK
REL="NEXT"
TITLE="array_diff"
HREF="function.array-diff.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-count-values.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-diff.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
></TABLE
><HR
ALIGN="LEFT"
WIDTH="100%"></DIV
><H1
><A
NAME="function.array-diff-assoc"
></A
>array_diff_assoc</H1
><DIV
CLASS="refnamediv"
><A
NAME="AEN4771"
></A
><P
>    (PHP 4 &#62;= 4.3.0)</P
>array_diff_assoc&nbsp;--&nbsp;Computes the difference of arrays with additional index check</DIV
><DIV
CLASS="refsect1"
><A
NAME="AEN4774"
></A
><H2
>Description</H2
>array <B
CLASS="methodname"
>array_diff_assoc</B
> ( array array1, array array2 [, array ...])<BR
></BR
><P
>&#13;     <B
CLASS="function"
>array_diff_assoc()</B
> returns an <A
HREF="language.types.array.html"
><B
CLASS="type"
>array</B
></A
>
     containing all the values from <TT
CLASS="parameter"
><I
>array1</I
></TT
>
     that are not present in any of the other arguments.
     Note that the keys are used in the comparison unlike 
     <A
HREF="function.array-diff.html"
><B
CLASS="function"
>array_diff()</B
></A
>.
    </P
><P
>&#13;     <TABLE
WIDTH="100%"
BORDER="0"
CELLPADDING="0"
CELLSPACING="0"
CLASS="EXAMPLE"
><TR
><TD
><DIV
CLASS="example"
><A
NAME="AEN4794"
></A
><P
><B
>Ejemplo 1. <B
CLASS="function"
>array_diff_assoc()</B
> example</B
></P
><TABLE
BORDER="0"
BGCOLOR="#E0E0E0"
CELLPADDING="5"
><TR
><TD
><PRE
CLASS="php"
>&#60;?php
$array1 = array ("a" =&#62; "green", "b" =&#62; "brown", "c" =&#62; "blue", "red");
$array2 = array ("a" =&#62; "green", "yellow", "red");
$result = array_diff_assoc ($array1, $array2);

/* The result is:
Array
(
    [b] =&#62; brown
    [c] =&#62; blue
    [0] =&#62; red
)
*/
?&#62;</PRE
></TD
></TR
></TABLE
></DIV
></TD
></TR
></TABLE
>
    </P
><P
>&#13;     In our example above you see the <TT
CLASS="literal"
>"a" =&#62; "green"</TT
>
     pair is present in both arrays and thus it is not in the ouput from the
     function. Unlike this, the pair <TT
CLASS="literal"
>0 =&#62; "red"</TT
> 
     is in the ouput because in the second argument <TT
CLASS="literal"
>"red"</TT
>
     has key which is <TT
CLASS="literal"
>1</TT
>. 
    </P
><P
>&#13;     Two values from <SPAN
CLASS="emphasis"
><I
CLASS="emphasis"
>key =&#62; value</I
></SPAN
> pairs are
     considered equal only if <TT
CLASS="literal"
>(string) $elem1 === (string)
     $elem2 </TT
>. In other words a strict check takes place so 
     the string representations must be the same.
     
    </P
><DIV
CLASS="note"
><BLOCKQUOTE
CLASS="note"
><P
><B
>Nota: </B
>
      Please note that this function only checks one dimension of a n-dimensional
      array. Of course you can check deeper dimensions by using, for example, 
      <TT
CLASS="literal"
>array_diff_assoc($array1[0], $array2[0]);</TT
>.
     </P
></BLOCKQUOTE
></DIV
><P
>&#13;     See also <A
HREF="function.array-diff.html"
><B
CLASS="function"
>array_diff()</B
></A
>,
     <A
HREF="function.array-intersect.html"
><B
CLASS="function"
>array_intersect()</B
></A
>,
     and <A
HREF="function.array-intersect-assoc.html"
><B
CLASS="function"
>array_intersect_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-count-values.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-diff.html"
ACCESSKEY="N"
>Siguiente</A
></TD
></TR
><TR
><TD
WIDTH="33%"
ALIGN="left"
VALIGN="top"
>array_count_values</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_diff</TD
></TR
></TABLE
></DIV
></BODY
></HTML
>