Annotation of embedaddon/php/ext/standard/tests/strings/sprintf_variation24.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: Test sprintf() function : usage variations - char formats with array values
3: --FILE--
4: <?php
5: /* Prototype : string sprintf(string $format [, mixed $arg1 [, mixed ...]])
6: * Description: Return a formatted string
7: * Source code: ext/standard/formatted_print.c
8: */
9:
10: echo "*** Testing sprintf() : char formats with array values ***\n";
11:
12: // array of array values
13: $array_values = array(
14: array(),
15: array(0),
16: array(1),
17: array(NULL),
18: array(null),
19: array("string"),
20: array(true),
21: array(TRUE),
22: array(false),
23: array(FALSE),
24: array(1,2,3,4),
25: array(1 => "One", "two" => 2)
26: );
27:
28: // array of char formats
29: $char_formats = array(
30: "%c", "%hc", "%lc",
31: "%Lc", " %c", "%c ",
32: "\t%c", "\n%c", "%4c",
33: "%30c", "%[a-bA-B@#$&]", "%*c"
34: );
35:
36: $count = 1;
37: foreach($array_values as $array_value) {
38: echo "\n-- Iteration $count --\n";
39:
40: foreach($char_formats as $format) {
41: var_dump( sprintf($format, $array_value) );
42: }
43: $count++;
44: };
45:
46: echo "Done";
47: ?>
48: --EXPECTF--
49: *** Testing sprintf() : char formats with array values ***
50:
51: -- Iteration 1 --
52: string(1) "