2 /* Prototype : string vsprintf(string format, array args)
3 * Description: Output a formatted string
4 * Source code: ext/standard/formatted_print.c
8 * Test vprintf() when different scientific formats and scientific values
9 * are passed to the '$format' and '$args' arguments of the function
12 echo "*** Testing vprintf() : scientific formats and scientific values ***\n";
14 // defining array of scientific formats
18 '%10.4e %-10.4e %.4e',
19 '%\'#20e %\'20e %\'$20e %\'_20e',
23 // Arrays of scientific values for the format defined in $format.
24 // Each sub array contains scientific values which correspond to each format string in $format
26 array(0, 1e0
, "10e2" ),
27 array(2.2e2
, 10e10
, 1000e-2, 1000e7
),
28 array(-22e12
, 10e20
, 1.2e2
),
29 array(1e1
, +
1e2
, -1e3
, "1e2_"),
30 array(3e3
, 4e3
, 1e3
, 2e3
)
33 // looping to test vprintf() with different scientific formats from the above $format array
34 // and with signed and other types of values from the above $args_array array
36 foreach($formats as $format) {
37 echo "\n-- Iteration $counter --\n";
38 $result = vprintf($format, $args_array[$counter-1]);