<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.strings.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'function.strnatcmp.php',
    1 => 'strnatcmp',
    2 => 'Confronto tra stringhe con l\'algoritmo dell\' &quot;ordine naturale&quot;',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Funzioni',
  ),
  'prev' => 
  array (
    0 => 'function.strnatcasecmp.php',
    1 => 'strnatcasecmp',
  ),
  'next' => 
  array (
    0 => 'function.strncasecmp.php',
    1 => 'strncasecmp',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'it',
    'path' => 'reference/strings/functions/strnatcmp.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strnatcmp" class="refentry">
   <div class="refnamediv">
    <h1 class="refname">strnatcmp</h1>
    <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strnatcmp</span> &mdash; <span class="dc-title">
     Confronto tra stringhe con l&#039;algoritmo dell&#039; &quot;ordine naturale&quot;
    </span></p>

   </div>
   <div class="refsect1 unknown-1408" id="refsect1-function.strnatcmp-unknown-1408">
    <h3 class="title">Descrizione</h3>
     <div class="methodsynopsis dc-description">
      <span class="methodname"><strong>strnatcmp</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$str1</code></span>, <span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$str2</code></span>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

    <p class="para rdfs-comment">
     Questa funzione implementa un algoritmo di confronto che ordina
     le stringhe alfa-numeriche nel modo con cui lo avrebbe fatto un uomo,
     questo è detto &quot;ordinamento naturale&quot;. Un esempio della differenza tra
     questo algoritmo e quello solito dei computer
     (utilizzato da <span class="function"><a href="function.strcmp.php" class="function">strcmp()</a></span>) è illustrato 
     di seguito:
     <div class="informalexample">
      <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$arr1 </span><span style="color: #007700">= </span><span style="color: #0000BB">$arr2 </span><span style="color: #007700">= array(</span><span style="color: #DD0000">"img12.png"</span><span style="color: #007700">, </span><span style="color: #DD0000">"img10.png"</span><span style="color: #007700">, </span><span style="color: #DD0000">"img2.png"</span><span style="color: #007700">, </span><span style="color: #DD0000">"img1.png"</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Standard string comparison\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">usort</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr1</span><span style="color: #007700">, </span><span style="color: #DD0000">"strcmp"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr1</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"\nNatural order string comparison\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">usort</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr2</span><span style="color: #007700">, </span><span style="color: #DD0000">"strnatcmp"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr2</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
      </div>

     </div>
     Il precedente codice visualizzerà:
     <div class="informalexample">
      <div class="example-contents screen">
<div class="annotation-interactive cdata"><pre>
Standard string comparison
Array
(
    [0] =&gt; img1.png
    [1] =&gt; img10.png
    [2] =&gt; img12.png
    [3] =&gt; img2.png
)

Natural order string comparison
Array
(
    [0] =&gt; img1.png
    [1] =&gt; img2.png
    [2] =&gt; img10.png
    [3] =&gt; img12.png
)
</pre></div>
      </div>
     </div>
     Per maggiori informazioni vedere: Martin Pool&#039;s <a href="https://github.com/sourcefrog/natsort" class="link external">&raquo;&nbsp;Natural Order String Comparison</a>
     page.
    </p>
    <p class="simpara">
     Al pari delle altre funzioni di confronto tra stringhe, questa restituisce
     &lt; 0 se <code class="parameter">str1</code> è minore di
     <code class="parameter">str2</code>; &gt; 0 se
     <code class="parameter">str1</code> è maggiore di
     <code class="parameter">str2</code>, e 0 se sono uguali.
    </p>
    <p class="simpara">
     Nota questo confronto distingue tra lettere maiuscole e minuscole.
    </p>
    <p class="simpara">
     Vedere anche <span class="function"><strong>ereg()</strong></span>,
     <span class="function"><a href="function.strcasecmp.php" class="function">strcasecmp()</a></span>, <span class="function"><a href="function.substr.php" class="function">substr()</a></span>,
     <span class="function"><a href="function.stristr.php" class="function">stristr()</a></span>, <span class="function"><a href="function.strcmp.php" class="function">strcmp()</a></span>,
     <span class="function"><a href="function.strncmp.php" class="function">strncmp()</a></span>, <span class="function"><a href="function.strncasecmp.php" class="function">strncasecmp()</a></span>,
     <span class="function"><a href="function.strnatcasecmp.php" class="function">strnatcasecmp()</a></span>, <span class="function"><a href="function.strstr.php" class="function">strstr()</a></span>, 
     <span class="function"><a href="function.natsort.php" class="function">natsort()</a></span> e <span class="function"><a href="function.natcasesort.php" class="function">natcasesort()</a></span>.
    </p>
   </div>

  </div><?php manual_footer($setup); ?>