<?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 => 'fr',
  ),
  'this' => 
  array (
    0 => 'function.count-chars.php',
    1 => 'count_chars',
    2 => 'Retourne des statistiques sur les caract&egrave;res utilis&eacute;s dans une cha&icirc;ne',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'Fonctions sur les cha&icirc;nes de caract&egrave;res',
  ),
  'prev' => 
  array (
    0 => 'function.convert-uuencode.php',
    1 => 'convert_uuencode',
  ),
  'next' => 
  array (
    0 => 'function.crc32.php',
    1 => 'crc32',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'fr',
    'path' => 'reference/strings/functions/count-chars.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.count-chars" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">count_chars</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">count_chars</span> &mdash; <span class="dc-title">Retourne des statistiques sur les caractères utilisés dans une chaîne</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.count-chars-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>count_chars</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>, <span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$mode</code><span class="initializer"> = 0</span></span>): <span class="type"><span class="type"><a href="language.types.array.php" class="type array">array</a></span>|<span class="type"><a href="language.types.string.php" class="type string">string</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>count_chars()</strong></span> compte le nombre d&#039;occurrences de
   tous les octets présents dans la chaîne <code class="parameter">string</code> 
   et retourne différentes statistiques.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.count-chars-parameters">
  <h3 class="title">Liste de paramètres</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       La chaîne analysée.
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       Voir les valeurs retournées.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.count-chars-returnvalues">
  <h3 class="title">Valeurs de retour</h3>
  <p class="para">
   Suivant la valeur de <code class="parameter">mode</code>, <span class="function"><strong>count_chars()</strong></span>
   retourne les informations suivantes :
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      0 : un tableau avec l&#039;octet en index, et la fréquence
      correspondante pour chaque octet.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      1 : identique à 0, mais seules les fréquences supérieures à
      zéro sont listées.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      2 : identique à 0, mais seules les fréquences nulles sont listées.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      3 : une chaîne contenant tous les octets utilisés est retournée.
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      4 : une chaîne contenant tous les octets non utilisés est retournée.
     </span>
    </li>
   </ul>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.count-chars-changelog">
  <h3 class="title">Historique</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       Antérieur à cette version, la fonction retournait <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> en cas d&#039;échec.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.count-chars-examples">
  <h3 class="title">Exemples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Exemple #1 Exemple avec <span class="function"><strong>count_chars()</strong></span></strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$data </span><span style="color: #007700">= </span><span style="color: #DD0000">"Deux D et un F."</span><span style="color: #007700">;<br /><br />foreach (</span><span style="color: #0000BB">count_chars</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">) as </span><span style="color: #0000BB">$i </span><span style="color: #007700">=&gt; </span><span style="color: #0000BB">$val</span><span style="color: #007700">) {<br />   echo </span><span style="color: #DD0000">"Il y a </span><span style="color: #0000BB">$val</span><span style="color: #DD0000"> occurrence(s) de \"" </span><span style="color: #007700">, </span><span style="color: #0000BB">chr</span><span style="color: #007700">(</span><span style="color: #0000BB">$i</span><span style="color: #007700">) , </span><span style="color: #DD0000">"\" dans la phrase.\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>L&#039;exemple ci-dessus va afficher :</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Il y a 4 occurrence(s) de &quot; &quot; dans la phrase.
Il y a 1 occurrence(s) de &quot;.&quot; dans la phrase.
Il y a 2 occurrence(s) de &quot;D&quot; dans la phrase.
Il y a 1 occurrence(s) de &quot;F&quot; dans la phrase.
Il y a 2 occurrence(s) de &quot;e&quot; dans la phrase.
Il y a 1 occurrence(s) de &quot;n&quot; dans la phrase.
Il y a 1 occurrence(s) de &quot;t&quot; dans la phrase.
Il y a 2 occurrence(s) de &quot;u&quot; dans la phrase.
Il y a 1 occurrence(s) de &quot;x&quot; dans la phrase.</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.count-chars-seealso">
  <h3 class="title">Voir aussi</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.strpos.php" class="function" rel="rdfs-seeAlso">strpos()</a> - Cherche la position de la premi&egrave;re occurrence dans une cha&icirc;ne</span></li>
    <li><span class="function"><a href="function.substr-count.php" class="function" rel="rdfs-seeAlso">substr_count()</a> - Compte le nombre d'occurrences de segments dans une cha&icirc;ne</span></li>
   </ul>
  </p>
 </div>


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