<?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.sscanf.php',
    1 => 'sscanf',
    2 => '&Uuml;bertr&auml;gt einen String in ein angegebenes Format',
  ),
  'up' => 
  array (
    0 => 'ref.strings.php',
    1 => 'String-Funktionen',
  ),
  'prev' => 
  array (
    0 => 'function.sprintf.php',
    1 => 'sprintf',
  ),
  'next' => 
  array (
    0 => 'function.str-contains.php',
    1 => 'str_contains',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'de',
    'path' => 'reference/strings/functions/sscanf.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.sscanf" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">sscanf</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.1, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">sscanf</span> &mdash; <span class="dc-title">Überträgt einen String in ein angegebenes Format</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.sscanf-description">
  <h3 class="title">Beschreibung</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">function</span> <span class="methodname"><strong>sscanf</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.string.php" class="type string">string</a></span> <code class="parameter">$format</code></span>, <span class="methodparam"><span class="type"><a href="language.types.mixed.php" class="type mixed">mixed</a></span> <code class="parameter reference">&...$vars</code></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 class="type"><a href="language.types.null.php" class="type null">null</a></span></span></div>

  <p class="simpara">
   Die Funktion <span class="function"><strong>sscanf()</strong></span> ist das Eingabegegenstück zu
   <span class="function"><a href="function.printf.php" class="function">printf()</a></span>. <span class="function"><strong>sscanf()</strong></span> liest den String
   <code class="parameter">string</code> und interpretiert ihn entsprechend dem
   übergegebenen <code class="parameter">format</code>-Parameter.
  </p>
  <p class="simpara">
   Beliebige Whitespaces im Formatstring entsprechen beliebigen Whitespaces im
   Inputstring. Das heißt, dass auch ein Tabulator (<code class="literal">\t</code>) im
   Formatstring einem einzelnen Leerzeichen des Inputstrings entsprechen kann.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.sscanf-parameters">
  <h3 class="title">Parameter-Liste</h3>
  <dl>
   
    <dt><code class="parameter">string</code></dt>
    <dd>
     <span class="simpara">
      Der zu parsende Eingabe<span class="type"><a href="language.types.string.php" class="type string">string</a></span>.
     </span>
    </dd>
   
   

     <dt><code class="parameter">format</code></dt>
     <dd>
      <p class="para">
       Das interpretierte Format für <code class="parameter">string</code>, wie es in
       der Dokumentation zu <span class="function"><a href="function.sprintf.php" class="function">sprintf()</a></span> beschrieben ist, mit
       den folgenden Unterschieden:
       <ul class="simplelist">
        <li>
         Die Funktion beachtet die Locale nicht.
        </li>
        <li>
         <code class="literal">F</code>, <code class="literal">g</code>, <code class="literal">G</code> und
         <code class="literal">b</code> werden nicht unterstützt.
        </li>
        <li>
         <code class="literal">D</code> steht für eine Dezimalzahl.
        </li>
        <li>
         <code class="literal">i</code> steht für eine Ganzzahl mit Angabe der Basis.
        </li>
        <li>
         <code class="literal">n</code> steht für die Anzahl der bisher verarbeiteten Zeichen.
        </li>
        <li>
         <code class="literal">s</code> beendet das Lesen beim ersten Whitespace-Zeichen.
        </li>
        <li>
         <code class="literal">*</code> anstelle von <code class="literal">argnum$</code>
         unterdrückt die Zuweisung dieser Umwandlungsspezifikation.
        </li>
       </ul>
      </p>
     </dd>
    

   
    <dt><code class="parameter">vars</code></dt>
    <dd>
     <span class="simpara">
      Optionale als Referenz übergebene Variablen, die die geparsten Werte
      enthalten.
     </span>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.sscanf-returnvalues">
  <h3 class="title">Rückgabewerte</h3>
  <p class="simpara">
   Werden nur 2 Parameter an die Funktion übergeben, werden die analysierten
   Werte als <span class="type"><a href="language.types.array.php" class="type array">array</a></span> zurückgegeben. Andernfalls, wenn optionale
   Parameter übergeben wurden, gibt die Funktion die Anzahl der ermittelten
   Werte zurück. Die optionalen Parameter müssen als Referenz übergeben werden.
  </p>
  <p class="simpara">
   Werden mehr Teilzeichenketten in <code class="parameter">format</code> erwartet
   als in <code class="parameter">string</code> verfügbar sind, wird <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>
   zurückgegeben.
  </p>
  <p class="simpara">
   Wenn optionale Parameter verwendet werden und das Ende des Eingabestrings
   <code class="parameter">string</code> erreicht wird, bevor ein Wert geparst werden
   konnte, wird <code class="literal">-1</code> zurückgegeben.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.sscanf-examples">
  <h3 class="title">Beispiele</h3>
  <div class="example" id="example-1">
   <p><strong>Beispiel #1 <span class="function"><strong>sscanf()</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 /></span><span style="color: #FF8000">// Ermittlung der Serien-Nr.<br /></span><span style="color: #007700">list(</span><span style="color: #0000BB">$serial</span><span style="color: #007700">) = </span><span style="color: #0000BB">sscanf</span><span style="color: #007700">(</span><span style="color: #DD0000">"SN/2350001"</span><span style="color: #007700">, </span><span style="color: #DD0000">"SN/%d"</span><span style="color: #007700">);<br /></span><span style="color: #FF8000">// und des Herstellungsdatums<br /></span><span style="color: #0000BB">$mandate </span><span style="color: #007700">= </span><span style="color: #DD0000">"Januar 01 2000"</span><span style="color: #007700">;<br />list(</span><span style="color: #0000BB">$monat</span><span style="color: #007700">, </span><span style="color: #0000BB">$tag</span><span style="color: #007700">, </span><span style="color: #0000BB">$jahr</span><span style="color: #007700">) = </span><span style="color: #0000BB">sscanf</span><span style="color: #007700">(</span><span style="color: #0000BB">$mandate</span><span style="color: #007700">, </span><span style="color: #DD0000">"%s %d %d"</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"Das Teil </span><span style="color: #0000BB">$serial</span><span style="color: #DD0000"> wurde hergestellt am: "<br />     </span><span style="color: #007700">. </span><span style="color: #DD0000">"</span><span style="color: #0000BB">$jahr</span><span style="color: #DD0000">-" </span><span style="color: #007700">. </span><span style="color: #0000BB">substr</span><span style="color: #007700">(</span><span style="color: #0000BB">$monat</span><span style="color: #007700">, </span><span style="color: #0000BB">0</span><span style="color: #007700">, </span><span style="color: #0000BB">3</span><span style="color: #007700">) . </span><span style="color: #DD0000">"-</span><span style="color: #0000BB">$tag</span><span style="color: #DD0000">\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
  <p class="simpara">
   Werden optionale Parameter übergeben, gibt die Funktion die Anzahl
   der ermittelten Werte zurück.
  </p>
  <div class="example" id="example-2">
   <p><strong>Beispiel #2 <span class="function"><strong>sscanf()</strong></span> - Verwendung optionaler Parameter</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">// Auslesen der Autoren-Info und Erzeugung eines DocBook-Eintrages<br /></span><span style="color: #0000BB">$auth </span><span style="color: #007700">= </span><span style="color: #DD0000">"24\tLewis Carroll"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">$n </span><span style="color: #007700">= </span><span style="color: #0000BB">sscanf</span><span style="color: #007700">(</span><span style="color: #0000BB">$auth</span><span style="color: #007700">, </span><span style="color: #DD0000">"%d\t%s %s"</span><span style="color: #007700">, </span><span style="color: #0000BB">$id</span><span style="color: #007700">, </span><span style="color: #0000BB">$first</span><span style="color: #007700">, </span><span style="color: #0000BB">$last</span><span style="color: #007700">);<br />echo </span><span style="color: #DD0000">"&lt;author id='</span><span style="color: #0000BB">$id</span><span style="color: #DD0000">'&gt;<br />    &lt;firstname&gt;</span><span style="color: #0000BB">$first</span><span style="color: #DD0000">&lt;/firstname&gt;<br />    &lt;surname&gt;</span><span style="color: #0000BB">$last</span><span style="color: #DD0000">&lt;/surname&gt;<br />&lt;/author&gt;\n"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
   </div>

  </div>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.sscanf-seealso">
  <h3 class="title">Siehe auch</h3>
  <ul class="simplelist">
   <li><span class="function"><a href="function.printf.php" class="function" rel="rdfs-seeAlso">printf()</a> - Liefert einen formatierten String</span></li>
   <li><span class="function"><a href="function.sprintf.php" class="function" rel="rdfs-seeAlso">sprintf()</a> - Gibt einen formatierten String zur&uuml;ck</span></li>
   <li><span class="function"><a href="function.fprintf.php" class="function" rel="rdfs-seeAlso">fprintf()</a> - Schreibt einen formatierten String in einen Stream</span></li>
   <li><span class="function"><a href="function.vprintf.php" class="function" rel="rdfs-seeAlso">vprintf()</a> - Gibt einen formatierten String aus</span></li>
   <li><span class="function"><a href="function.vsprintf.php" class="function" rel="rdfs-seeAlso">vsprintf()</a> - Gibt einen formatierten String zur&uuml;ck</span></li>
   <li><span class="function"><a href="function.vfprintf.php" class="function" rel="rdfs-seeAlso">vfprintf()</a> - Schreibt einen formatierten String in einen Stream</span></li>
   <li><span class="function"><a href="function.fscanf.php" class="function" rel="rdfs-seeAlso">fscanf()</a> - Interpretiert den Input einer Datei entsprechend einem
   angegebenen Format</span></li>
   <li><span class="function"><a href="function.number-format.php" class="function" rel="rdfs-seeAlso">number_format()</a> - Formatiert eine Zahl mit Tausender-Trennzeichen</span></li>
   <li><span class="function"><a href="function.date.php" class="function" rel="rdfs-seeAlso">date()</a> - Formatiert einen Unix-Zeitstempel</span></li>
  </ul>
 </div>


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