mirror of
https://github.com/php/doc-de.git
synced 2026-03-29 10:42:12 +02:00
git-svn-id: https://svn.php.net/repository/phpdoc/de/trunk@212900 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.5 $ -->
|
|
<!-- EN-Revision: 1.5 Maintainer: sammywg Status: ready -->
|
|
<refentry id="function.strnatcmp">
|
|
<refnamediv>
|
|
<refname>strnatcmp</refname>
|
|
<refpurpose>
|
|
String-Vergleich unter Verwendung einer "natürlichen Ordnung"
|
|
</refpurpose>
|
|
</refnamediv>
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<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>
|
|
Diese Funktion implemetiert einen Vergleichsalgorithmus, der
|
|
alphanumerische Zeichenketten "menschlich" ordnet (auch "natürliche
|
|
Ordnung" genannt). Der Unterschied zwischen dieser und der regulären
|
|
String-Sortierung eines Computers (wie sie <function>strcmp</function>
|
|
verwendet) wird in dem folgenden Beispiel gezeigt:
|
|
<informalexample>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$arr1 = $arr2 = array("img12.png", "img10.png", "img2.png", "img1.png");
|
|
echo "Normaler String-Vergleich\n";
|
|
usort($arr1, "strcmp");
|
|
print_r($arr1);
|
|
echo "\nVergleich mittels natürlicher Ordnung\n";
|
|
usort($arr2, "strnatcmp");
|
|
print_r($arr2);
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</informalexample>
|
|
Der o.a. Code erzeugt die folgende Ausgabe:
|
|
<informalexample>
|
|
<screen>
|
|
<![CDATA[
|
|
Normaler String-Vergleich
|
|
Array
|
|
(
|
|
[0] => img1.png
|
|
[1] => img10.png
|
|
[2] => img12.png
|
|
[3] => img2.png
|
|
)
|
|
|
|
Vergleich mittels natürlicher Ordnung
|
|
Array
|
|
(
|
|
[0] => img1.png
|
|
[1] => img2.png
|
|
[2] => img10.png
|
|
[3] => img12.png
|
|
)
|
|
]]>
|
|
</screen>
|
|
</informalexample>
|
|
Weitere Informationen finden Sie auf Martin Pools <ulink
|
|
url="&url.strnatcmp;">Natural Order String Comparison</ulink>-Seite.
|
|
</para>
|
|
<simpara>
|
|
Ähnlich anderen String-Vergleichs-Funktionen gibt diese < 0
|
|
zurück, wenn <parameter>str1</parameter> kleiner ist als
|
|
<parameter>str2</parameter>, bzw. > 0, wenn
|
|
<parameter>str1</parameter> größer ist als
|
|
<parameter>str2</parameter>, oder 0, wenn sie gleich sind.
|
|
</simpara>
|
|
<simpara>
|
|
Dieser Vergleich berücksichtigt Groß- und Kleinschreibung.
|
|
</simpara>
|
|
<simpara>
|
|
Siehe auch
|
|
<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> und
|
|
<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
|
|
-->
|