mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-29 20:32:10 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/fr/trunk@167786 c90b9560-bf6c-de11-be94-00142212c4b1
113 lines
3.2 KiB
XML
113 lines
3.2 KiB
XML
<?xml version="1.0" encoding="iso-8859-1"?>
|
|
<!-- $Revision: 1.10 $ -->
|
|
<!-- EN-Revision: 1.5 Maintainer: didou Status: ready -->
|
|
<refentry id="function.strnatcmp">
|
|
<refnamediv>
|
|
<refname>strnatcmp</refname>
|
|
<refpurpose>
|
|
Comparaison de chaînes avec l'algorithme d'"ordre naturel"
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1>
|
|
<title>Description</title>
|
|
<methodsynopsis>
|
|
<type>int</type><methodname>strnatcmp</methodname>
|
|
<methodparam><type>string</type><parameter>str1</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>str2</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
<function>strnatcmp</function> implémente l'algorithme
|
|
de comparaison qui ordonne les chaînes tel qu'un homme
|
|
le ferai. Cette fonction est similaire à la fonction
|
|
<function>strnatcmp</function>, mais la comparaison n'est pas
|
|
sensible à la casse. Un exemple de la différence de
|
|
traitement avec l'algorithme standard est présenté ci-dessous :
|
|
<example>
|
|
<title>Exemple avec <function>strnatcmp</function></title>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$arr1 = $arr2 = array("img12.png", "img10.png", "img2.png", "img1.png");
|
|
echo "Tri de chaînes standard\n";
|
|
usort($arr1, "strcmp");
|
|
print_r($arr1);
|
|
echo "\nTri de chaînes \"ordre naturel\"\n";
|
|
usort($arr2, "strnatcmp");
|
|
print_r($arr2);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
&example.outputs;
|
|
<screen>
|
|
<![CDATA[
|
|
Tri de chaînes standard
|
|
Array
|
|
(
|
|
[0] => img1.png
|
|
[1] => img10.png
|
|
[2] => img12.png
|
|
[3] => img2.png
|
|
)
|
|
|
|
Tri de chaînes "ordre naturel"
|
|
Array
|
|
(
|
|
[0] => img1.png
|
|
[1] => img2.png
|
|
[2] => img10.png
|
|
[3] => img12.png
|
|
)
|
|
]]>
|
|
</screen>
|
|
</example>
|
|
Pour plus de détails, reportez-vous à
|
|
<ulink url="&url.strnatcmp;"><literal>Natural Order String Comparison</literal></ulink>
|
|
de Martin Pool (en anglais).
|
|
</para>
|
|
<simpara>
|
|
<function>strnatcmp</function> retourne < 0 si <parameter>str1</parameter>
|
|
est inférieure à <parameter>str2</parameter>; > 0 si <parameter>str1</parameter>
|
|
est supérieure à <parameter>str2</parameter>, et 0 si les deux chaînes
|
|
sont égales.
|
|
</simpara>
|
|
<simpara>
|
|
Notez que cette comparaison est sensible à la casse.
|
|
</simpara>
|
|
<simpara>
|
|
Voir aussi
|
|
<function>ereg</function>,
|
|
<function>strcasecmp</function>,
|
|
<function>substr</function>,
|
|
<function>stristr</function>,
|
|
<function>strcmp</function>,
|
|
<function>strncmp</function>,
|
|
<function>strncasecmp</function>,
|
|
<function>strnatcasecmp</function>,
|
|
<function>strstr</function>,
|
|
<function>natsort</function> et
|
|
<function>natcasesort</function>.
|
|
</simpara>
|
|
</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
|
|
-->
|