import zend standard tests
[hiphop-php.git] / hphp / test / zend / good / ext-standard-strings / vsprintf_variation8.php
blobc004b05c90acb39793c5fbf0bd5bb8eb7c38c4ae
1 <?php
2 /* Prototype : string vsprintf(string format, array args)
3 * Description: Return a formatted string
4 * Source code: ext/standard/formatted_print.c
5 */
7 /*
8 * Test vsprintf() when different string formats and non-string values are passed to
9 * the '$format' and '$args' arguments of the function
12 error_reporting(E_ALL & ~E_NOTICE);
14 echo "*** Testing vsprintf() : string formats and non-string values ***\n";
16 // defining array of string formats
17 $formats =
18 '%s %+s %-s
19 %ls %4s %-4s
20 %10.4s %-10.4s %04s %04.4s
21 %\'#2s %\'2s %\'$2s %\'_2s
22 %3$s %4$s %1$s %2$s';
24 // Arrays of non string values for the format defined in $format.
25 // Each sub array contains non string values which correspond to each format in $format
26 $args_array = array(
28 // array of float values
29 array(2.2, .2, 10.2,
30 123456.234, -1234.6789, +1234.6789,
31 2.1234567e10, +2.7654321e10, -2.7654321e10, 2.1234567e10,
32 12345.780, 12.000000011111, -12.00000111111, -123456.234,
33 3.33, +4.44, 1.11,-2.22 ),
35 // array of int values
36 array(2, -2, +2,
37 123456, -12346789, +12346789,
38 123200, +20000, -40000, 22212,
39 12345780, 1211111, -12111111, -12345634,
40 3, +4, 1,-2 ),
43 // different arrays
44 array( array(0), array(1, 2), array(-1, -1),
45 array("123"), array('-123'), array("-123"),
46 array(true), array(false), array(TRUE), array(FALSE),
47 array("123hello"), array("1", "2"), array('123hello'), array(12=>"12twelve"),
48 array("3"), array("4"), array("1"), array("2") ),
50 // array of boolean data
51 array( true, TRUE, false,
52 TRUE, FALSE, 1,
53 true, false, TRUE, FALSE,
54 0, 1, 1, 0,
55 1, TRUE, 0, FALSE),
59 // looping to test vsprintf() with different string formats from the above $format array
60 // and with non-string values from the above $args_array array
61 $counter = 1;
62 foreach($args_array as $args) {
63 echo "\n-- Iteration $counter --\n";
64 var_dump( vsprintf($formats, $args) );
65 $counter++;
69 ===DONE===