<?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.explode.php',
    1 => 'explode',
    2 => 'Teilt eine Zeichenkette anhand einer Zeichenkette',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.echo.php',
    1 => 'echo',
  ),
  'next' => 
  array (
    0 => 'function.fprintf.php',
    1 => 'fprintf',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/strings/functions/explode.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.explode" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">explode</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">explode</span> &mdash; <span class="dc-title">Teilt eine Zeichenkette anhand einer Zeichenkette</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.explode-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>explode</strong></span>(<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$separator</code></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">$limit</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.php-int-max">PHP_INT_MAX</a></code></strong></span></span>): <span class="type"><a href="language.types.array.php" class="type array">array</a></span></div>

  <p class="para rdfs-comment">
   Gibt ein Array aus Zeichenketten zurück, die jeweils Teil von
   <code class="parameter">string</code> sind. Die Abtrennung erfolgt dabei an der mit
   <code class="parameter">separator</code> angegebenen Zeichenkette.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.explode-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">separator</code></dt>
     <dd>
      <p class="para">
       Die Begrenzungszeichenkette.
      </p>
     </dd>
    
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Die Eingabezeichenkette.
      </p>
     </dd>
    
    
     <dt><code class="parameter">limit</code></dt>
     <dd>
      <p class="para">
       Ist der Parameter <code class="parameter">limit</code> angegeben und positiv,
       enthält das zurückgegebene Array maximal <code class="parameter">limit</code>
       Elemente, wobei das letzte Element den Rest von
       <code class="parameter">string</code> beinhaltet.
      </p>
      <p class="para">
       Ist der Parameter <code class="parameter">limit</code> negativ, werden alle
       Teilzeichenketten bis auf die letzten
       -<code class="parameter">limit</code>-Teile zurückgegeben.
      </p>
      <p class="para">
       Wenn der Parameter <code class="parameter">limit</code> gleich 0 ist, wird er
       wie 1 behandelt.
      </p>
     </dd>
    
   </dl>
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Vor PHP 8.0 akzeptierte <span class="function"><a href="function.implode.php" class="function">implode()</a></span> die Parameter in
    beliebiger Reihenfolge. <span class="function"><strong>explode()</strong></span> hat dies nie
    unterstützt. Stellen Sie daher sicher, dass Sie den Parameter
    <code class="parameter">separator</code> vor dem Parameter
    <code class="parameter">string</code> notieren.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.explode-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt ein <span class="type"><a href="language.types.array.php" class="link">Array</a></span> von <span class="type"><a href="language.types.string.php" class="link">String</a></span>s zurück, die
   durch Aufsplitten des Parameters <code class="parameter">string</code> an
   Begrenzungen durch <code class="parameter">separator</code> erzeugt werden.
  </p>
  <p class="para">
   Ist <code class="parameter">separator</code> eine leere Zeichenkette (&quot;&quot;), so löst
   <span class="function"><strong>explode()</strong></span> einen <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> aus. Enthält
   <code class="parameter">separator</code> einen Wert, der nicht in
   <code class="parameter">string</code> vorkommt und wird ein negativer Wert für
   <code class="parameter">limit</code> verwendet, wird ein leeres
   <span class="type"><a href="language.types.array.php" class="link">Array</a></span> zurückgegeben. Für alle anderen Werte von
   <code class="parameter">limit</code> wird ein <span class="type"><a href="language.types.array.php" class="link">Array</a></span> zurückgegeben,
   das <code class="parameter">string</code> als einziges Element enthält. Wenn
   <code class="parameter">separator</code> am Anfang oder am Ende von
   <code class="parameter">string</code> steht, wird ein leeres <span class="type"><a href="language.types.array.php" class="link">Array</a></span>
   an den Anfang bzw. das Ende des zurückgegebenen <span class="type"><a href="language.types.array.php" class="link">Array</a></span>s
   angehängt.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.explode-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.0.0</td>
      <td>
       <span class="function"><strong>explode()</strong></span> löst nun einen
       <span class="classname"><a href="class.valueerror.php" class="classname">ValueError</a></span> aus, wenn an den Parameter
       <code class="parameter">separator</code> eine leere Zeichenkette
       (<code class="literal">&quot;&quot;</code>) übergeben wird.
       Bisher gab <span class="function"><strong>explode()</strong></span> stattdessen <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.explode-examples">
  <h3 class="title">Beispiele</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Beispiel #1 <span class="function"><strong>explode()</strong></span>-Beispiele</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">// Beispiel 1<br /></span><span style="color: #0000BB">$pizza  </span><span style="color: #007700">= </span><span style="color: #DD0000">"Teil1 Teil2 Teil3 Teil4 Teil5 Teil6"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$teile </span><span style="color: #007700">= </span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">" "</span><span style="color: #007700">, </span><span style="color: #0000BB">$pizza</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$teile</span><span style="color: #007700">[</span><span style="color: #0000BB">0</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// Teil1<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$teile</span><span style="color: #007700">[</span><span style="color: #0000BB">1</span><span style="color: #007700">], </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// Teil2<br /><br />// Beispiel 2<br /></span><span style="color: #0000BB">$data </span><span style="color: #007700">= </span><span style="color: #DD0000">"foo:*:1023:1000::/home/foo:/bin/sh"</span><span style="color: #007700">;<br />list(</span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">$pass</span><span style="color: #007700">, </span><span style="color: #0000BB">$uid</span><span style="color: #007700">, </span><span style="color: #0000BB">$gid</span><span style="color: #007700">, </span><span style="color: #0000BB">$gecos</span><span style="color: #007700">, </span><span style="color: #0000BB">$home</span><span style="color: #007700">, </span><span style="color: #0000BB">$shell</span><span style="color: #007700">) = </span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">":"</span><span style="color: #007700">, </span><span style="color: #0000BB">$data</span><span style="color: #007700">);<br />echo </span><span style="color: #0000BB">$user</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// foo<br /></span><span style="color: #007700">echo </span><span style="color: #0000BB">$pass</span><span style="color: #007700">, </span><span style="color: #0000BB">PHP_EOL</span><span style="color: #007700">; </span><span style="color: #FF8000">// *<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
  <p class="para">
   <div class="example" id="example-2">
    <p><strong>Beispiel #2 <span class="function"><strong>explode()</strong></span>-Rückgabebeispiele</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /></span><span style="color: #FF8000">/*<br />   Eine Zeichenkette, die nicht das Trennzeichen enthält, wird einfach<br />   ein ein-elementiges Array mit der ursprünglichen Zeichenkette liefern.<br />*/<br /></span><span style="color: #0000BB">$input1 </span><span style="color: #007700">= </span><span style="color: #DD0000">"hallo"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$input2 </span><span style="color: #007700">= </span><span style="color: #DD0000">"hallo,da"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$input3 </span><span style="color: #007700">= </span><span style="color: #DD0000">','</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">explode</span><span style="color: #007700">( </span><span style="color: #DD0000">','</span><span style="color: #007700">, </span><span style="color: #0000BB">$input1 </span><span style="color: #007700">) );<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">explode</span><span style="color: #007700">( </span><span style="color: #DD0000">','</span><span style="color: #007700">, </span><span style="color: #0000BB">$input2 </span><span style="color: #007700">) );<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">( </span><span style="color: #0000BB">explode</span><span style="color: #007700">( </span><span style="color: #DD0000">','</span><span style="color: #007700">, </span><span style="color: #0000BB">$input3 </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(1)
(
    [0] =&gt; string(5) &quot;hallo&quot;
)
array(2)
(
    [0] =&gt; string(5) &quot;hallo&quot;
    [1] =&gt; string(5) &quot;da&quot;
)
array(2)
(
    [0] =&gt; string(0) &quot;&quot;
    [1] =&gt; string(0) &quot;&quot;
)</pre>
</div>
    </div>
   </div>
  </p>
  <p class="para">
   <div class="example" id="example-3">
    <p><strong>Beispiel #3 <code class="parameter">limit</code>-Parameterbeispiele</strong></p>
    <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$str </span><span style="color: #007700">= </span><span style="color: #DD0000">'eins|zwei|drei|vier'</span><span style="color: #007700">;<br /><br /></span><span style="color: #FF8000">// positiver Wert in "limit"<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'|'</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 /><br /></span><span style="color: #FF8000">// negative Wert in "limit"<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">explode</span><span style="color: #007700">(</span><span style="color: #DD0000">'|'</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">?&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; eins
    [1] =&gt; zwei|drei|vier
)
Array
(
    [0] =&gt; eins
    [1] =&gt; zwei
    [2] =&gt; drei
)</pre>
</div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.explode-notes">
  <h3 class="title">Anmerkungen</h3>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: <span class="simpara">Diese Funktion ist
binärsicher.</span></p></blockquote>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.explode-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <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.str-split.php" class="function" rel="rdfs-seeAlso">str_split()</a> - Konvertiert einen String in ein Array</span></li>
    <li><span class="function"><a href="function.mb-split.php" class="function" rel="rdfs-seeAlso">mb_split()</a> - Split multibyte string using regular expression</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><span class="function"><a href="function.strtok.php" class="function" rel="rdfs-seeAlso">strtok()</a> - Zerlegt einen String</span></li>
    <li><span class="function"><a href="function.implode.php" class="function" rel="rdfs-seeAlso">implode()</a> - Verbindet Array-Elemente zu einem String</span></li>
   </ul>
  </p>
 </div>


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