1--TEST--
2Test vsprintf() function : usage variations - scientific formats with scientific values
3--FILE--
4<?php
5/*
6 * Test vprintf() when different scientific formats and scientific values
7 * are passed to the '$format' and '$args' arguments of the function
8*/
9
10echo "*** Testing vprintf() : scientific formats and scientific values ***\n";
11
12// defining array of scientific formats
13$formats = array(
14  '%e %+e %-e',
15  '%le %4e %-4e',
16  '%10.4e %-10.4e %.4e',
17  '%\'#20e %\'20e %\'$20e %\'_20e',
18  '%3$e %4$e %1$e %2$e'
19);
20
21// Arrays of scientific values for the format defined in $format.
22// Each sub array contains scientific values which correspond to each format string in $format
23$args_array = array(
24  array(0, 1e0, "10e2" ),
25  array(2.2e2, 1000e-2, 1000e7),
26  array(-22e12, 10e20, 1.2e2),
27  array(1e1, +1e2, -1e3, "1e2_"),
28  array(3e3, 4e3, 1e3, 2e3)
29);
30
31// looping to test vprintf() with different scientific formats from the above $format array
32// and with signed and other types of  values from the above $args_array array
33$counter = 1;
34foreach($formats as $format) {
35  echo "\n-- Iteration $counter --\n";
36  $result = vprintf($format, $args_array[$counter-1]);
37  echo "\n";
38  var_dump($result);
39  $counter++;
40}
41
42?>
43--EXPECT--
44*** Testing vprintf() : scientific formats and scientific values ***
45
46-- Iteration 1 --
470.000000e+0 +1.000000e+0 1.000000e+3
48int(36)
49
50-- Iteration 2 --
512.200000e+2 1.000000e+1 1.000000e+10
52int(36)
53
54-- Iteration 3 --
55-2.2000e+13 1.0000e+21 1.2000e+2
56int(32)
57
58-- Iteration 4 --
59#########1.000000e+1 1.000000e+2 $$$$$$$$-1.000000e+3 _________1.000000e+2
60int(74)
61
62-- Iteration 5 --
631.000000e+3 2.000000e+3 3.000000e+3 4.000000e+3
64int(47)
65