<?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 => 'ja',
  ),
  'this' => 
  array (
    0 => 'function.count-chars.php',
    1 => 'count_chars',
    2 => '文字列で使用されている文字に関する情報を返す',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String 関数',
  ),
  'prev' => 
  array (
    0 => 'function.convert-uuencode.php',
    1 => 'convert_uuencode',
  ),
  'next' => 
  array (
    0 => 'function.crc32.php',
    1 => 'crc32',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'ja',
    '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">文字列で使用されている文字に関する情報を返す</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.count-chars-description">
  <h3 class="title">説明</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">
   <code class="parameter">string</code> において各バイト値 (0..255)
   が存在する数をかぞえ、様々な手法で返します。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.count-chars-parameters">
  <h3 class="title">パラメータ</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       調べたい文字列。
      </p>
     </dd>
    
    
     <dt><code class="parameter">mode</code></dt>
     <dd>
      <p class="para">
       戻り値を参照ください。
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.count-chars-returnvalues">
  <h3 class="title">戻り値</h3>
  <p class="para">
   <code class="parameter">mode</code> の値により、
   <span class="function"><strong>count_chars()</strong></span> は以下の値のどれかを返します。
   <ul class="itemizedlist">
    <li class="listitem">
     <span class="simpara">
      0 - 各バイト値をキー、各バイトの出現回数を値とする配列。
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      1 - 0と同じですが、各バイト値の出現回数がゼロより大きいものの一覧となります。
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      2 - 0と同じですが、各バイト値の出現回数がゼロであるものの一覧となります。
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      3 - すべての一意な文字を含む文字列を返します。
     </span>
    </li>
    <li class="listitem">
     <span class="simpara">
      4 - 使用されていない全ての文字を含む文字列を返します。
     </span>
    </li>
   </ul>
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.count-chars-changelog">
  <h3 class="title">変更履歴</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>バージョン</th>
      <th>説明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       これより前のバージョンでは、この関数は失敗時に <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> を返していました。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.count-chars-examples">
  <h3 class="title">例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>例1 <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">"Two Ts and one 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">"There were </span><span style="color: #0000BB">$val</span><span style="color: #DD0000"> instance(s) of \"" </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">"\" in the string.\n"</span><span style="color: #007700">;<br />}<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

    <div class="example-contents"><p>上の例の出力は以下となります。</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">There were 4 instance(s) of &quot; &quot; in the string.
There were 1 instance(s) of &quot;.&quot; in the string.
There were 1 instance(s) of &quot;F&quot; in the string.
There were 2 instance(s) of &quot;T&quot; in the string.
There were 1 instance(s) of &quot;a&quot; in the string.
There were 1 instance(s) of &quot;d&quot; in the string.
There were 1 instance(s) of &quot;e&quot; in the string.
There were 2 instance(s) of &quot;n&quot; in the string.
There were 2 instance(s) of &quot;o&quot; in the string.
There were 1 instance(s) of &quot;s&quot; in the string.
There were 1 instance(s) of &quot;w&quot; in the string.</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.count-chars-seealso">
  <h3 class="title">参考</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.strpos.php" class="function" rel="rdfs-seeAlso">strpos()</a> - 文字列内の部分文字列が最初に現れる場所を見つける</span></li>
    <li><span class="function"><a href="function.substr-count.php" class="function" rel="rdfs-seeAlso">substr_count()</a> - 副文字列の出現回数を数える</span></li>
   </ul>
  </p>
 </div>


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