What is PhpDig?
PhpDig is a PHP MySQL based
Web Spider & Search Engine.



sscanf — Parses input from a string according to a specified format.


mixed sscanf(string, format[, $variables]);
string string: String to parse
string format: Format to use
mixed $variables (optional): One or more variables to store


Integer or array; FALSE on error


sscanf() parses string into variables based on the format string. The format string uses the same conversion specifiers as sprintf() ; however, instead of formatting and transforming variables, it provides a template with which to parse a string into variables. See sprintf() for a complete list of conversion specifiers.

This function accepts two or more arguments. If only two arguments are provided, the data parsed from string are returned as a numerically keyed array. If additional arguments are passed to the function, the data parsed out of string are stored in them. If there are more specifiers than variables to contain them, an error is generated. If the opposite is true, the extra variables contain NULL .


sscanf() is best suited to dealing with simple strings that follow consistent fixed formats. For more robust functionality, use the Perl-style regular expression library.


PHP 4.0.1+

See also

To create a formatted string from multiple arguments:



Example 1216. Parse data out of a simple formatted string

$string = 'age:27 height:1.83m weight:90kg';
sscanf($string, 'age:%d height:%fm weight:%dkg', $age, $height, $weight);

// use var_dump to show the types, as well as the values
var_dump($age, $height, $weight);


PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at The authors of this book have elected not to choose any options under the OPL. This online book was obtained from and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.

Powered by: vBulletin Version 3.0.7
Copyright ©2000 - 2005, Jelsoft Enterprises Ltd.
Copyright © 2001 - 2005, ThinkDing LLC. All Rights Reserved.