1
0
mirror of https://github.com/php/doc-fr.git synced 2026-03-24 07:02:06 +01:00
Files
archived-doc-fr/reference/array/functions/array-diff.xml
Jean-Sébastien Goupil dcbd76b0cc sync with EN
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@222717 c90b9560-bf6c-de11-be94-00142212c4b1
2006-11-03 12:03:58 +00:00

101 lines
2.8 KiB
XML

<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.20 $ -->
<!-- EN-Revision: 1.12 Maintainer: dams Status: ready -->
<!-- Reviewed: no -->
<refentry id="function.array-diff">
<refnamediv>
<refname>array_diff</refname>
<refpurpose>Calcule la différence entre deux tableaux</refpurpose>
</refnamediv>
<refsect1>
&reftitle.description;
<methodsynopsis>
<type>array</type><methodname>array_diff</methodname>
<methodparam><type>array</type><parameter>array1</parameter></methodparam>
<methodparam><type>array</type><parameter>array2</parameter></methodparam>
<methodparam choice="opt"><type>array</type><parameter> ...</parameter></methodparam>
</methodsynopsis>
<para>
<function>array_diff</function> retourne un tableau
qui contient toutes les valeurs du tableau <parameter>array1</parameter>
qui sont absentes de tous les autres arguments <parameter>array2</parameter>,
<parameter>...</parameter>, etc. Notez que les clés sont préservées.
</para>
<para>
<example>
<title>Exemple avec <function>array_diff</function></title>
<programlisting role="php">
<![CDATA[
<?php
$array1 = array ("a" => "vert", "rouge", "bleu", "rouge");
$array2 = array ("b" => "vert", "jaune", "rouge");
$result = array_diff ($array1, $array2);
print_r($result);
?>
]]>
</programlisting>
<para>
Les valeurs multiples dans <parameter>array1</parameter> seront toutes
traitées de la même façon.
</para>
&example.outputs;
<screen>
<![CDATA[
Array
(
[1] => bleu
)
]]>
</screen>
</example>
</para>
<note>
<simpara>
Deux éléments sont considérés comme égaux si et seulement si
<literal>(string) $elem1 === (string) $elem2</literal>. En clair :
lorsque la représentation en chaîne de caractères est identique.
</simpara>
</note>
<note>
<simpara>
Notez que cette fonction ne vérifie qu'une dimension d'un tableau à n-dimensions.
Bien sur, vous pouvez vérifier des dimensions plus profondes en utilisant
<literal>array_diff($array1[0], $array2[0]);</literal>.
</simpara>
</note>
<warning>
<simpara>
Cette fonction était inutilisable en &php; 4.0.4!
</simpara>
</warning>
<para>
Voir aussi
<function>array_diff_assoc</function>,
<function>array_intersect</function> et
<function>array_intersect_assoc</function>.
</para>
</refsect1>
</refentry>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->