<?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-split.php',
    1 => 'str_split',
    2 => 'Convert a string to an array',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String Функції',
  ),
  'prev' => 
  array (
    0 => 'function.str-shuffle.php',
    1 => 'str_shuffle',
  ),
  'next' => 
  array (
    0 => 'function.str-starts-with.php',
    1 => 'str_starts_with',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/strings/functions/str-split.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.str-split" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">str_split</h1>
  <p class="verinfo">(PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">str_split</span> &mdash; <span class="dc-title">Convert a string to an array</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.str-split-description">
  <h3 class="title">Опис</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>str_split</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">$length</code><span class="initializer"> = 1</span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Converts a string to an array. 
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-split-parameters">
  <h3 class="title">Параметри</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       The input string.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Maximum length of the chunk.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-split-returnvalues">
  <h3 class="title">Значення, що повертаються</h3>
  <p class="para">
   If the optional <code class="parameter">length</code> parameter is
   specified, the returned array will be broken down into chunks with each
   being <code class="parameter">length</code> in length, except the final chunk
   which may be shorter if the string does not divide evenly.  The default
   <code class="parameter">length</code> is <code class="literal">1</code>, meaning every chunk will be one byte in size.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.str-split-errors">
  <h3 class="title">Помилки/виключення</h3>
  <p class="para">
   If <code class="parameter">length</code> is less than <code class="literal">1</code>,
   a <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> will be thrown.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.str-split-changelog">
  <h3 class="title">Журнал змін</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Версія</th>
      <th>Опис</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.2.0</td>
      <td>
       If <code class="parameter">string</code> is empty an empty <span class="type"><a href="language.types.array.php" class="type array">array</a></span> is now returned.
       Previously an <span class="type"><a href="language.types.array.php" class="type array">array</a></span> containing a single empty string was returned.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       If <code class="parameter">length</code> is less than <code class="literal">1</code>,
       a <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> will be thrown now;
       previously, an error of level <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong>
       has been raised instead, and the function returned <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.str-split-examples">
  <h3 class="title">Приклади</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Приклад #1 Example uses of <span class="function"><strong>str_split()</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 /><br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">"Hello Friend"</span><span style="color: #007700">;<br /><br /></span><span style="color: #0000BB">$arr1 </span><span style="color: #007700">= </span><span style="color: #0000BB">str_split</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$arr2 </span><span style="color: #007700">= </span><span style="color: #0000BB">str_split</span><span style="color: #007700">(</span><span style="color: #0000BB">$str</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">);<br /><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 /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">$arr2</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; H
    [1] =&gt; e
    [2] =&gt; l
    [3] =&gt; l
    [4] =&gt; o
    [5] =&gt;
    [6] =&gt; F
    [7] =&gt; r
    [8] =&gt; i
    [9] =&gt; e
    [10] =&gt; n
    [11] =&gt; d
)

Array
(
    [0] =&gt; Hel
    [1] =&gt; lo
    [2] =&gt; Fri
    [3] =&gt; end
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-split-notes">
  <h3 class="title">Примітки</h3>
  <blockquote class="note"><p><strong class="note">Зауваження</strong>: 
   <p class="para">
    <span class="function"><strong>str_split()</strong></span> will split into bytes, rather than characters when dealing with a multi-byte encoded string.
    <span class="function"><a href="function.mb-str-split.php" class="function">mb_str_split()</a></span> can be used to split the string into code points.
    <span class="function"><a href="function.grapheme-str-split.php" class="function">grapheme_str_split()</a></span> can be used to split the string into grapheme clusters.
   </p>
  </p></blockquote>
 </div>

 
 <div class="refsect1 seealso" id="refsect1-function.str-split-seealso">
  <h3 class="title">Прогляньте також</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.mb-str-split.php" class="function" rel="rdfs-seeAlso">mb_str_split()</a> - Given a multibyte string, return an array of its characters</span></li>
    <li><span class="function"><a href="function.grapheme-str-split.php" class="function" rel="rdfs-seeAlso">grapheme_str_split()</a> - Split a string into an array</span></li>
    <li><span class="function"><a href="function.chunk-split.php" class="function" rel="rdfs-seeAlso">chunk_split()</a> - Split a string into smaller chunks</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.explode.php" class="function" rel="rdfs-seeAlso">explode()</a> - Розбиває рядок на підрядки</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.str-word-count.php" class="function" rel="rdfs-seeAlso">str_word_count()</a> - Return information about words used in a string</span></li>
    <li><a href="control-structures.for.php" class="link">for</a></li>
   </ul>
  </p>
 </div>


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