<?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.strcspn.php',
    1 => 'strcspn',
    2 => 'Ermittelt die Anzahl der nicht &uuml;bereinstimmenden Zeichen',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.strcoll.php',
    1 => 'strcoll',
  ),
  'next' => 
  array (
    0 => 'function.strip-tags.php',
    1 => 'strip_tags',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/strings/functions/strcspn.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.strcspn" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">strcspn</h1>
  <p class="verinfo">(PHP 4, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">strcspn</span> &mdash; <span class="dc-title">Ermittelt die Anzahl der nicht übereinstimmenden Zeichen</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.strcspn-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>strcspn</strong></span>(<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$string</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.string.php" class="type string">string</a></span> <code class="parameter">$characters</code></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<span class="methodparam"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span> <code class="parameter">$offset</code><span class="initializer"> = 0</span></span>,<br>&nbsp;&nbsp;&nbsp;&nbsp;<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.integer.php" class="type int">int</a></span></span> <code class="parameter">$length</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span><br>): <span class="type"><a href="language.types.integer.php" class="type int">int</a></span></div>

  <p class="para rdfs-comment">
   Gibt die Länge des Anfangssegments von <code class="parameter">string</code>
   zurück, bis zu der <em>kein</em> Zeichen aus
   <code class="parameter">characters</code> vorkommt.
  </p>
  <p class="para">
   Wenn die Parameter <code class="parameter">offset</code> und
   <code class="parameter">length</code> weggelassen werden, dann wird
   <code class="parameter">string</code> komplett untersucht. Werden sie angegeben,
   dann ist es gleichwertig zum Aufruf von <code class="literal">strcspn(substr($string,
   $offset, $length), $characters)</code> (für weitere Informationen siehe
   <a href="function.substr.php" class="xref">substr</a>).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.strcspn-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">string</code></dt>
     <dd>
      <p class="para">
       Die zu untersuchende Zeichenkette.
      </p>
     </dd>
    
    
     <dt><code class="parameter">characters</code></dt>
     <dd>
      <p class="para">
       Die Zeichenkette, die alle nicht erlaubten Zeichen enthält.
      </p>
     </dd>
    
    
     <dt><code class="parameter">offset</code></dt>
     <dd>
      <p class="para">
       Die Position in <code class="parameter">string</code>, an der die Suche beginnt.
      </p>
      <p class="para">
       Wird <code class="parameter">offset</code> angegeben und ist nicht negativ,
       dann beginnt <span class="function"><strong>strcspn()</strong></span><code class="parameter">string</code>
       an der Position <code class="parameter">offset</code> zu untersuchen.
       Beispielsweise ist in der Zeichenkette &#039;<code class="literal">abcdef</code>&#039; das
       Zeichen an Position <code class="literal">0</code> ein &#039;<code class="literal">a</code>&#039;,
       das Zeichen an Position <code class="literal">2</code> ein
       &#039;<code class="literal">c</code>&#039;, usw.
      </p>
      <p class="para">
       Wird <code class="parameter">offset</code> angegeben und ist negativ, dann
       beginnt <span class="function"><strong>strcspn()</strong></span> <code class="parameter">string</code> an
       der Position <code class="parameter">offset</code> vom Ende von
       <code class="parameter">string</code> aus betrachtet zu untersuchen.
      </p>
     </dd>
    
    
     <dt><code class="parameter">length</code></dt>
     <dd>
      <p class="para">
       Die Länge des Segments von <code class="parameter">string</code>, das untersucht
       werden soll.
      </p>
      <p class="para">
       Wird <code class="parameter">length</code> angegeben und ist nicht negativ,
       dann werden bis zu <code class="parameter">length</code> Zeichen von
       <code class="parameter">string</code> nach der Anfangsposition untersucht.
      </p>
      <p class="para">
       Wird <code class="parameter">length</code> angegeben und ist negativ, dann
       wird <code class="parameter">string</code> von der Anfangsposition bis zu
       <code class="parameter">length</code> Zeichen vom Ende von
       <code class="parameter">string</code> aus betrachtet untersucht.
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.strcspn-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="para">
   Gibt die Länge des Anfangssegments von <code class="parameter">string</code>
   zurück, das ausschließlich aus Zeichen besteht, die
   <em>nicht</em> in <code class="parameter">characters</code> vorkommen.
  </p>
  <blockquote class="note"><p><strong class="note">Hinweis</strong>: 
   <p class="para">
    Wird der Parameter <code class="parameter">offset</code> angegeben, zählt die
    zurückgegebene Länge von dieser Position aus, nicht vom Anfang von
    <code class="parameter">string</code>.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.strcspn-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.4.0</td>
      <td>
       <span class="simpara">
        Wenn vor PHP 8.4.0 <code class="parameter">characters</code> eine leere
        Zeichenkette war, wurde die Suche fälschlicherweise beim ersten
        Null-Byte in <code class="parameter">string</code> beendet.
       </span>
      </td>
     </tr>

     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">length</code> ist jetzt nullable (akzeptiert den
       <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>-Wert).
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.strcspn-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="strcspn.example">
   <p><strong>Beispiel #1 <span class="function"><strong>strcspn()</strong></span>-Beispiel</strong></p>
   <div class="example-contents">
<div class="annotation-interactive phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br />$a </span><span style="color: #007700">= </span><span style="color: #0000BB">strcspn</span><span style="color: #007700">(</span><span style="color: #DD0000">'banana'</span><span style="color: #007700">, </span><span style="color: #DD0000">'a'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$b </span><span style="color: #007700">= </span><span style="color: #0000BB">strcspn</span><span style="color: #007700">(</span><span style="color: #DD0000">'banana'</span><span style="color: #007700">, </span><span style="color: #DD0000">'abcd'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$c </span><span style="color: #007700">= </span><span style="color: #0000BB">strcspn</span><span style="color: #007700">(</span><span style="color: #DD0000">'banana'</span><span style="color: #007700">, </span><span style="color: #DD0000">'z'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$d </span><span style="color: #007700">= </span><span style="color: #0000BB">strcspn</span><span style="color: #007700">(</span><span style="color: #DD0000">'abcdhelloabcd'</span><span style="color: #007700">, </span><span style="color: #DD0000">'a'</span><span style="color: #007700">, -</span><span style="color: #0000BB">9</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$e </span><span style="color: #007700">= </span><span style="color: #0000BB">strcspn</span><span style="color: #007700">(</span><span style="color: #DD0000">'abcdhelloabcd'</span><span style="color: #007700">, </span><span style="color: #DD0000">'a'</span><span style="color: #007700">, -</span><span style="color: #0000BB">9</span><span style="color: #007700">, -</span><span style="color: #0000BB">5</span><span style="color: #007700">);<br /><br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$a</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$b</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$c</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$d</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">var_dump</span><span style="color: #007700">(</span><span style="color: #0000BB">$e</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">int(1)
int(0)
int(6)
int(5)
int(4)</pre>
</div>
   </div>
  </div>
 </div>


 <div class="refsect1 notes" id="refsect1-function.strcspn-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.strcspn-seealso">
  <h3 class="title">Siehe auch</h3>
  <p class="para">
   <ul class="simplelist">
    <li><span class="function"><a href="function.strspn.php" class="function" rel="rdfs-seeAlso">strspn()</a> - Ermittelt die L&auml;nge des initialen Abschnitts einer Zeichenkette, der
   ausschlie&szlig;lich aus Zeichen besteht, die in einer &uuml;bergebenen Maske
   enthalten sind</span></li>
   </ul>
  </p>
 </div>


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