1--TEST--
2Test sscanf() function : basic functionality - exponential format
3--FILE--
4<?php
5
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
9*/
10
11echo "*** Testing sscanf() : basic functionality -using exponential format ***\n";
12
13$str = "10.12345 10.12345E3 10.12345e3 -10.12345e4" ;
14$format1 = "%e %e %e %e";
15$format2 = "%E %E %E %E";
16
17echo "\n-- Try sccanf() WITHOUT optional args --\n";
18// extract details using short format
19list($arg1, $arg2, $arg3, $arg4) = sscanf($str, $format1);
20var_dump($arg1, $arg2, $arg3, $arg4);
21list($arg1, $arg2, $arg3, $arg4) = sscanf($str, $format2);
22var_dump($arg1, $arg2, $arg3, $arg4);
23
24echo "\n-- Try sccanf() WITH optional args --\n";
25// extract details using long  format
26$res = sscanf($str, $format1, $arg1, $arg2, $arg3, $arg4);
27var_dump($res, $arg1, $arg2, $arg3, $arg4);
28$res = sscanf($str, $format2,$arg1, $arg2, $arg3, $arg4);
29var_dump($res, $arg1, $arg2, $arg3, $arg4);
30
31
32?>
33===DONE===
34--EXPECT--
35*** Testing sscanf() : basic functionality -using exponential format ***
36
37-- Try sccanf() WITHOUT optional args --
38float(10.12345)
39float(10123.45)
40float(10123.45)
41float(-101234.5)
42float(10.12345)
43float(10123.45)
44float(10123.45)
45float(-101234.5)
46
47-- Try sccanf() WITH optional args --
48int(4)
49float(10.12345)
50float(10123.45)
51float(10123.45)
52float(-101234.5)
53int(4)
54float(10.12345)
55float(10123.45)
56float(10123.45)
57float(-101234.5)
58===DONE===
59