2 Test sscanf() function : basic functionality - float format
6 /* Prototype : mixed sscanf ( string $str , string $format [, mixed &$... ] )
7 * Description: Parses input from a string according to a format
8 * Source code: ext/standard/string.c
11 echo "*** Testing sscanf() : basic functionality -- using float format ***\n";
13 $str = "Part: Widget Length: 111.53 Width: 22.345 Depth: 12.4";
14 $format = "Part: %s Length: %f Width: %f Depth: %f";
16 echo "\n-- Try sccanf() WITHOUT optional args --\n";
17 // extract details using short format
18 list($part, $length, $width, $depth) = sscanf($str, $format);
19 var_dump($part, $length, $width, $depth);
21 echo "\n-- Try sccanf() WITH optional args --\n";
22 // extract details using long format
23 $res = sscanf($str, $format, $part, $length, $width, $depth);
24 var_dump($res, $part, $length, $width, $depth);
29 *** Testing sscanf() : basic functionality -- using float format ***
31 -- Try sccanf() WITHOUT optional args --
37 -- Try sccanf() WITH optional args --