import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / sscanf_basic1.php
blob3a3eab6d4d95bb8549f1b64e3d05f2b534d65b45
1 <?php
2 /* Prototype : mixed sscanf ( string $str , string $format [, mixed &$... ] )
3 * Description: Parses input from a string according to a format
4 * Source code: ext/standard/string.c
5 */
7 /*
8 * Testing sscanf() : basic functionality
9 */
11 echo "*** Testing sscanf() : basic functionality - using string format ***\n";
13 $str = "Part: Widget Serial Number: 1234789 Stock: 25";
14 $format = "Part: %s Serial Number: %s Stock: %s";
16 echo "\n-- Try sccanf() WITHOUT optional args --\n";
17 // extract details using short format
18 list($part, $number, $stock) = sscanf($str, $format);
19 var_dump($part, $number, $stock);
21 echo "\n-- Try sccanf() WITH optional args --\n";
22 // extract details using long format
23 $res = sscanf($str, $format, $part, $number, $stock);
24 var_dump($res, $part, $number, $stock);
27 ===DONE===