1--TEST-- 2Test sscanf() function : basic functionality - integer format 3--FILE-- 4<?php 5/* 6 * Testing sscanf() : basic functionality 7*/ 8 9echo "*** Testing sscanf() : basic functionality - using integer format ***\n"; 10 11$str = "Part: Widget Serial Number: 1234789 Stock: 25"; 12$format = "Part: %s Serial Number: %d Stock: %d"; 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 integer format *** 27 28-- Try sccanf() WITHOUT optional args -- 29string(6) "Widget" 30int(1234789) 31int(25) 32 33-- Try sccanf() WITH optional args -- 34int(3) 35string(6) "Widget" 36int(1234789) 37int(25) 38