1--TEST--
2Test sscanf() function : basic functionality - string format
3--FILE--
4<?php
5/*
6 * Testing sscanf() : basic functionality
7*/
8
9echo "*** Testing sscanf() : basic functionality - using string format ***\n";
10
11$str = "Part: Widget Serial Number: 1234789 Stock: 25";
12$format = "Part: %s Serial Number: %s Stock: %s";
13
14echo "\n-- Try sccanf() WITHOUT optional args --\n";
15// extract details using short format
16list($part, $number, $stock) = sscanf($str, $format);
17var_dump($part, $number, $stock);
18
19echo "\n-- Try sccanf() WITH optional args --\n";
20// extract details using long  format
21$res = sscanf($str, $format, $part, $number, $stock);
22var_dump($res, $part, $number, $stock);
23
24?>
25--EXPECT--
26*** Testing sscanf() : basic functionality - using string format ***
27
28-- Try sccanf() WITHOUT optional args --
29string(6) "Widget"
30string(7) "1234789"
31string(2) "25"
32
33-- Try sccanf() WITH optional args --
34int(3)
35string(6) "Widget"
36string(7) "1234789"
37string(2) "25"
38