1--TEST-- 2Test sscanf() function : basic functionality - float 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 float format ***\n"; 12 13$str = "Part: Widget Length: 111.53 Width: 22.345 Depth: 12.4"; 14$format = "Part: %s Length: %f Width: %f Depth: %f"; 15 16echo "\n-- Try sccanf() WITHOUT optional args --\n"; 17// extract details using short format 18list($part, $length, $width, $depth) = sscanf($str, $format); 19var_dump($part, $length, $width, $depth); 20 21echo "\n-- Try sccanf() WITH optional args --\n"; 22// extract details using long format 23$res = sscanf($str, $format, $part, $length, $width, $depth); 24var_dump($res, $part, $length, $width, $depth); 25 26?> 27===DONE=== 28--EXPECT-- 29*** Testing sscanf() : basic functionality -- using float format *** 30 31-- Try sccanf() WITHOUT optional args -- 32string(6) "Widget" 33float(111.53) 34float(22.345) 35float(12.4) 36 37-- Try sccanf() WITH optional args -- 38int(4) 39string(6) "Widget" 40float(111.53) 41float(22.345) 42float(12.4) 43===DONE=== 44