sscanf
(PHP4 >= 4.0.1)
SSCANF---&http://www.aliyun.com/zixun/aggregation/37954.html ">nbsp; Profiling Strings by format
Syntax: Mixed sscanf (String str, string format [, String var1 ...])
Description:
The sscanf () input parameter is similar to printf (), sscanf () reads the string str and interprets it according to the format specified. If you pass only two arguments to this function, the parsed value is returned as an array.
Example:
<?php
Getting the serial number
$serial = sscanf ("sn/2350001", "sn/%d");
and the date of manufacturing
$mandate = "whose 01 2000";
List ($month, $day, $year) = sscanf ($mandate, "%s%d%d");
echo "Item $serial is manufactured on: $year-". substr ($month, 0, 3). " -$day \ n ";
?>
If you pass a non-essential argument, the function returns the number of assigned values, and non-essential parameters must be passed by relationship.
Example:
<?php
Get author info and generate DocBook entry
$auth = "24\tlewis Carroll";
$n = sscanf ($auth, "%d\t%s%s", & $id, & $first, & $last);
echo "<author id= ' $id ' > <firstname> $first </firstname> <surname> $last </surname> </ Author>\n ";
?>
Reference: FSCANF () printf () sprintf ()