mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-27 18:32:09 +01:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@172675 c90b9560-bf6c-de11-be94-00142212c4b1
101 lines
2.5 KiB
XML
101 lines
2.5 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.16 $ -->
|
|
<!-- EN-Revision: 1.8 Maintainer: dams Status: ready -->
|
|
<refentry id="function.uasort">
|
|
<refnamediv>
|
|
<refname>uasort</refname>
|
|
<refpurpose>
|
|
Trie un tableau en utilisant une fonction de callback
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>uasort</methodname>
|
|
<methodparam><type>array</type><parameter role="reference">array</parameter></methodparam>
|
|
<methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>uasort</function> trie le tableau <parameter>array</parameter>
|
|
en conservant la correspondance entre les index et leurs valeurs.
|
|
<function>uasort</function> sert essentiellement lors de tri de tableaux
|
|
associatifs où l'ordre des éléments est significatif. La
|
|
fonction de comparaison utilisée <parameter>cmp_function</parameter>
|
|
est définie par l'utilisateur.
|
|
</para>
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>uasort</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
function compare ($a, $b) {
|
|
if ($a == $b) return 0;
|
|
return ($a > $b) ? -1 : 1;
|
|
}
|
|
|
|
$a = array (4 => "quatre", 3 => "trois", 20 => "vingt", 10 => "dix");
|
|
|
|
uasort ($a, "compare");
|
|
|
|
while (list ($key, $value) = each ($a)) {
|
|
echo "$key: $value\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
20: vingt
|
|
3: trois
|
|
4: quatre
|
|
10: dix
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<note>
|
|
<para>
|
|
Voyez les fonctions <function>usort</function> et
|
|
<function>uksort</function> pour des exemples de tris avec utilisation
|
|
de fonction personnalisée.
|
|
</para>
|
|
</note>
|
|
<para>
|
|
Voir aussi
|
|
<function>usort</function>,
|
|
<function>uksort</function>,
|
|
<function>sort</function>,
|
|
<function>asort</function>,
|
|
<function>arsort</function>,
|
|
<function>ksort</function> et
|
|
<function>rsort</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
|
|
-->
|