You are here : phpstringsscanf

sscanf() - string

The function sscanf() is the input analog of
   printf(). sscanf() reads
   from the string str and interprets it
   according to the specified format, which is
   described in the documentation for sprintf().
Parameters :
  • str - The input string being parsed.
  • format - The interpreted format for str, which is described in the documentation for sprintf() with following differences: Function is not locale-aware. F, g, G and b are not supported. D stands for decimal number. i stands for integer with base detection. n stands for number of characters processed so far.
  • ... - Optionally pass in variables by reference that will contain the parsed values.

  • Syntax

    mixed sscanf
        ( string $str
       , string $format
       [, mixed &$...
      ] )


    Example

    <?php// getting the serial numberlist($serial) = sscanf("SN/2350001", "SN/%d");// and the date of manufacturing$mandate = "January 01 2000";list($month, $day, $year) = sscanf($mandate, "%s %d %d");echo "Item $serial was manufactured on: $year-" . substr($month, 0, 3) . "-$day\n";?>


    Output / Return Value


    Limitations


    Alternatives / See Also


    Reference