<?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 => 'de',
  ),
  'this' => 
  array (
    0 => 'function.str-split.php',
    1 => 'str_split',
    2 => 'Konvertiert einen String in ein Array',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String-Funktionen',
  ),
  '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' => 'de',
    '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">Konvertiert einen String in ein Array</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.str-split-description">
  <h3 class="title">Beschreibung</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">
   Konvertiert eine Zeichenkette in ein Array.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.str-split-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Die Eingabezeichenkette
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Maximale Länge eines Teilstücks
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.str-split-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Wenn der optionale Parameter <code class="parameter">length</code> angegeben wurde,
   enthält das zurückgegebene Array Elemente mit der in
   <code class="parameter">length</code> definierten Länge. Eine Ausnahme bildet das
   letzte Teilstück, das kürzer sein kann, wenn die Zeichenkette nicht
   gleichmäßig aufgeteilt ist. Der Standardwert von
   <code class="parameter">length</code> ist <code class="literal">1</code>, was bedeutet, dass
   jeder Abschnitt ein Byte groß ist.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-function.str-split-errors">
  <h3 class="title">Fehler/Exceptions</h3>
  <p class="para">
   Wenn der Parameter <code class="parameter">length</code> kleiner ist als
   <code class="literal">1</code>, wird ein <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> ausgelöst.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.str-split-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Beschreibung</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.2.0</td>
      <td>
       Wenn <code class="parameter">string</code> eine leere Zeichenkette ist, wird
       nun ein leeres <a href="language.types.array.php" class="link">Array</a> zurückgegeben; davor wurde ein <a href="language.types.array.php" class="link">Array</a> mit einer
       einzelnen leeren Zeichenkette zurückgegeben.
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       Wenn der Parameter <code class="parameter">length</code> kleiner ist als
       <code class="literal">1</code>, wird nun ein <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span>
       ausgelöst; davor wurde ein Fehler der Stufe
       <strong><code><a href="errorfunc.constants.php#constant.e-warning">E_WARNING</a></code></strong> ausgelöst und die Funktion gab <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>
       zurück.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.str-split-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 Beispiel für die Verwendung von <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">"Hallo Freund"</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>Das oben gezeigte Beispiel erzeugt folgende Ausgabe:</p></div>
    <div class="example-contents screen">
<div class="annotation-interactive examplescode"><pre class="examplescode">Array
(
    [0] =&gt; H
    [1] =&gt; a
    [2] =&gt; l
    [3] =&gt; l
    [4] =&gt; o
    [5] =&gt;
    [6] =&gt; F
    [7] =&gt; r
    [8] =&gt; e
    [9] =&gt; u
    [10] =&gt; n
    [11] =&gt; d
)

Array
(
    [0] =&gt; Hal
    [1] =&gt; lo
    [2] =&gt; Fre
    [3] =&gt; und
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.str-split-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Bei einer mehrbytekodierten Zeichenkette zerlegt
    <span class="function"><strong>str_split()</strong></span> die Zeichenkette in Bytes statt in Zeichen.
    Mit <span class="function"><a href="function.mb-str-split.php" class="function">mb_str_split()</a></span> kann die Zeichenkette in Codepunkte
    zerlegt werden und mit <span class="function"><a href="function.grapheme-str-split.php" class="function">grapheme_str_split()</a></span> in
    Grapheme-Cluster.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.str-split-seealso">
  <h3 class="title">Siehe auch</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> - Zerlegt einen String in Teile gleicher L&auml;nge</span></li>
    <li><span class="function"><a href="function.preg-split.php" class="function" rel="rdfs-seeAlso">preg_split()</a> - Zerlegt eine Zeichenkette anhand eines regul&auml;ren Ausdrucks</span></li>
    <li><span class="function"><a href="function.explode.php" class="function" rel="rdfs-seeAlso">explode()</a> - Teilt eine Zeichenkette anhand einer Zeichenkette</span></li>
    <li><span class="function"><a href="function.count-chars.php" class="function" rel="rdfs-seeAlso">count_chars()</a> - Gibt Informationen &uuml;ber die in einem String enthaltenen Zeichen zur&uuml;ck</span></li>
    <li><span class="function"><a href="function.str-word-count.php" class="function" rel="rdfs-seeAlso">str_word_count()</a> - Liefert Informationen &uuml;ber in einem String verwendete Worte</span></li>
    <li><a href="control-structures.for.php" class="link">for</a></li>
   </ul>
  </p>
 </div>


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