<note> usort($arr, 'strnatcmp') to keep index/value associations.

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@88629 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Philip Olson 2002-07-14 01:16:48 +00:00
parent fa9c2436a6
commit 7e46cf0e18

View file

@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.4 $ -->
<!-- $Revision: 1.5 $ -->
<!-- splitted from ./en/functions/array.xml, last change in rev 1.25 -->
<refentry id="function.natsort">
<refnamediv>
@ -26,6 +26,7 @@
<title><function>natsort</function> example</title>
<programlisting role="php">
<![CDATA[
<?php
$array1 = $array2 = array ("img12.png", "img10.png", "img2.png", "img1.png");
sort($array1);
@ -35,6 +36,7 @@ print_r($array1);
natsort($array2);
echo "\nNatural order sorting\n";
print_r($array2);
?>
]]>
</programlisting>
</example>
@ -68,6 +70,12 @@ Array
url="&url.strnatcmp;">Natural Order String Comparison</ulink>
page.
</para>
<note>
<para>
If you're wanting to maintain index/value associations, consider
using <literal>usort($arr, 'strnatcmp')</literal>.
</para>
</note>
<para>
See also <function>natcasesort</function>,
<function>strnatcmp</function>, and