1--TEST--
2Test sscanf() function : basic functionality - char 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 char format ***\n";
12
13$str = "X = A + B - C";
14$format = "%c = %c + %c - %c";
15
16echo "\n-- Try sccanf() WITHOUT optional args --\n";
17// extract details using short format
18list($arg1, $arg2, $arg3, $arg4) = sscanf($str, $format);
19var_dump($arg1, $arg2, $arg3, $arg4);
20
21echo "\n-- Try sccanf() WITH optional args --\n";
22// extract details using long  format
23$res = sscanf($str, $format, $arg1, $arg2, $arg3, $arg4);
24var_dump($res, $arg1, $arg2, $arg3, $arg4);
25
26?>
27===DONE===
28--EXPECT--
29*** Testing sscanf() : basic functionality - using char format ***
30
31-- Try sccanf() WITHOUT optional args --
32string(1) "X"
33string(1) "A"
34string(1) "B"
35string(1) "C"
36
37-- Try sccanf() WITH optional args --
38int(4)
39string(1) "X"
40string(1) "A"
41string(1) "B"
42string(1) "C"
43===DONE===