<?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 => 'uk',
  ),
  'this' => 
  array (
    0 => 'function.str-word-count.php',
    1 => 'str_word_count',
    2 => 'Return information about words used in a string',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.str-starts-with.php',
    1 => 'str_starts_with',
  ),
  'next' => 
  array (
    0 => 'function.strcasecmp.php',
    1 => 'strcasecmp',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/str-word-count.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-word-count" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_word_count</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.3.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">str_word_count</span> &mdash; <span class="dc-title">
   Return information about words used in a string
  </span></p>

 </div>
 <div class="refsect1 description" id="refsect1-function.str-word-count-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_word_count</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">$format</code><span class="initializer"> = 0</span></span>, <span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.string.php" class="type string">string</a></span></span> <code class="parameter">$characters</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></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.integer.php" class="type int">int</a></span></span></div>

  <p class="para rdfs-comment">
   Counts the number of words inside <code class="parameter">string</code>. 
   If the optional <code class="parameter">format</code> is not specified, then 
   the return value will be an integer representing the number of words 
   found. In the event the <code class="parameter">format</code> is specified, the return
   value will be an array, content of which is dependent on the 
   <code class="parameter">format</code>. The possible value for the 
   <code class="parameter">format</code> and the resultant outputs are listed below.
  </p>
  <p class="para">
   For the purpose of this function, &#039;word&#039; is defined as a locale dependent
   string containing alphabetic characters, which also may contain, but not start
   with &quot;&#039;&quot; and &quot;-&quot; characters.
   Note that multibyte locales are not supported.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-word-count-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The string
      </p>
     </dd>
    
    
     <dt><code class="parameter">format</code></dt>
     <dd>
      <p class="para">
       Specify the return value of this function. The current supported values
       are:
       <ul class="itemizedlist">
        <li class="listitem">
         <span class="simpara">
          0 - returns the number of words found
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          1 - returns an array containing all the words found inside the
          <code class="parameter">string</code>
         </span>
        </li>
        <li class="listitem">
         <span class="simpara">
          2 - returns an associative array, where the key is the numeric
          position of the word inside the <code class="parameter">string</code> and
          the value is the actual word itself
         </span>
        </li> 
       </ul>
      </p>
     </dd>
    
    
     <dt><code class="parameter">characters</code></dt>
     <dd>
      <p class="para">
       A list of additional characters which will be considered as &#039;word&#039;
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-word-count-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   Returns an array or an integer, depending on the
   <code class="parameter">format</code> chosen.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.str-word-count-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>
       <code class="parameter">characters</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.str-word-count-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 A <span class="function"><strong>str_word_count()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"Hello fri3nd, you're<br />       looking          good today!"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">str_word_count</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">str_word_count</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">2</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">str_word_count</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">1</span><span style="color: #007700">, </span><span style="color: #DD0000">'àáãç3'</span><span style="color: #007700">));<br /><br />echo </span><span style="color: #0000BB">str_word_count</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</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">Array
(
    [0] =&gt; Hello
    [1] =&gt; fri
    [2] =&gt; nd
    [3] =&gt; you&#039;re
    [4] =&gt; looking
    [5] =&gt; good
    [6] =&gt; today
)

Array
(
    [0] =&gt; Hello
    [6] =&gt; fri
    [10] =&gt; nd
    [14] =&gt; you&#039;re
    [29] =&gt; looking
    [46] =&gt; good
    [51] =&gt; today
)

Array
(
    [0] =&gt; Hello
    [1] =&gt; fri3nd
    [2] =&gt; you&#039;re
    [3] =&gt; looking
    [4] =&gt; good
    [5] =&gt; today
)

7</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-word-count-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.explode.php" class="function" rel="rdfs-seeAlso">explode()</a> - Розбиває рядок на підрядки</span></li>
    <li><span class="function"><a href="function.preg-split.php" class="function" rel="rdfs-seeAlso">preg_split()</a> - Split string by a regular expression</span></li>
    <li><span class="function"><a href="function.count-chars.php" class="function" rel="rdfs-seeAlso">count_chars()</a> - Return information about characters used in a string</span></li>
    <li><span class="function"><a href="function.substr-count.php" class="function" rel="rdfs-seeAlso">substr_count()</a> - Count the number of substring occurrences</span></li>
   </ul>
  </p>
 </div>

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