mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-30 04:42:24 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@171861 c90b9560-bf6c-de11-be94-00142212c4b1
102 lines
2.6 KiB
XML
102 lines
2.6 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.18 $ -->
|
|
<!-- EN-Revision: 1.14 Maintainer: dams Status: ready -->
|
|
<refentry id="function.uksort">
|
|
<refnamediv>
|
|
<refname>uksort</refname>
|
|
<refpurpose>
|
|
Trie un tableau par ses clés en utilisant une fonction de callback
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>bool</type><methodname>uksort</methodname>
|
|
<methodparam><type>array</type><parameter>&array</parameter></methodparam>
|
|
<methodparam><type>callback</type><parameter>cmp_function</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>uksort</function> trie les clés du tableau <parameter>array</parameter>
|
|
en utilisant la fonction utilisateur <parameter>cmp_function</parameter>.
|
|
Si un tableau doit être
|
|
trié avec un critère complexe, il est préférable
|
|
d'utiliser <function>uksort</function>.
|
|
</para>
|
|
<para>
|
|
La fonction <parameter>cmp_function</parameter> doit accepter deux
|
|
paramètres, qui représenteront une paire de clé du tableau
|
|
<parameter>array</parameter>. La fonction de comparaison doit retourner
|
|
un entier supérieur, égal ou inférieur à zéro, pour, respectivement,
|
|
indiquer que le premier argument est supérieur, égal ou inférieur
|
|
au second.
|
|
</para>
|
|
<para>
|
|
&return.success;
|
|
</para>
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>uksort</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");
|
|
|
|
uksort ($a, "compare");
|
|
|
|
while (list ($key, $value) = each ($a)) {
|
|
echo "$key: $value\n";
|
|
}
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
20: vingt
|
|
10: dix
|
|
4: quatre
|
|
3: trois
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
</para>
|
|
<para>
|
|
Voir aussi
|
|
<function>usort</function>,
|
|
<function>uasort</function>,
|
|
<function>sort</function>,
|
|
<function>asort</function>,
|
|
<function>arsort</function>,
|
|
<function>ksort</function>,
|
|
<function>natsort</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
|
|
-->
|