1--TEST--
2Test sscanf() function : basic functionality - hexadecimal format
3--FILE--
4<?php
5
6echo "*** Testing sscanf() : basic functionality - - using hexadecimal format ***\n";
7
8$str = "129 12F 123B -123B 01ABC 1G";
9$format1 = "%x %x %x %x %x %x";
10$format2 = "%X %X %X %X %X %X";
11
12echo "\n-- Try sccanf() WITHOUT optional args --\n";
13// extract details using short format
14list($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) = sscanf($str, $format1);
15var_dump($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
16list($arg1, $arg2, $arg3, $arg4, $arg5, $arg6) = sscanf($str, $format2);
17var_dump($arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
18
19echo "\n-- Try sccanf() WITH optional args --\n";
20// extract details using long  format
21$res = sscanf($str, $format1, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
22var_dump($res, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
23$res = sscanf($str, $format2, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
24var_dump($res, $arg1, $arg2, $arg3, $arg4, $arg5, $arg6);
25
26?>
27--EXPECT--
28*** Testing sscanf() : basic functionality - - using hexadecimal format ***
29
30-- Try sccanf() WITHOUT optional args --
31int(297)
32int(303)
33int(4667)
34int(-4667)
35int(6844)
36int(1)
37int(297)
38int(303)
39int(4667)
40int(-4667)
41int(6844)
42int(1)
43
44-- Try sccanf() WITH optional args --
45int(6)
46int(297)
47int(303)
48int(4667)
49int(-4667)
50int(6844)
51int(1)
52int(6)
53int(297)
54int(303)
55int(4667)
56int(-4667)
57int(6844)
58int(1)
59