1--TEST--
2Test fprintf() function (variation - 2)
3--SKIPIF--
4<?php
5$data_file = dirname(__FILE__) . '/dump.txt';
6if (!($fp = fopen($data_file, 'w'))) {
7  die('skip File dump.txt could not be created');
8}
9?>
10--FILE--
11<?php
12
13$int_variation = array( "%d", "%-d", "%+d", "%7.2d", "%-7.2d", "%07.2d", "%-07.2d", "%'#7.2d" );
14$int_numbers = array( 0, 1, -1, 2.7, -2.7, 23333333, -23333333, "1234" );
15
16/* creating dumping file */
17$data_file = dirname(__FILE__) . '/dump.txt';
18if (!($fp = fopen($data_file, 'wt')))
19   return;
20
21$counter = 1;
22/* integer type variations */
23fprintf($fp, "\n*** Testing fprintf() with integers ***\n");
24foreach( $int_variation as $int_var ) {
25  fprintf( $fp, "\n-- Iteration %d --\n",$counter);
26  foreach( $int_numbers as $int_num ) {
27    fprintf( $fp, "\n");
28    fprintf( $fp, $int_var, $int_num );
29  }
30  $counter++;
31}
32
33fclose($fp);
34
35print_r(file_get_contents($data_file));
36echo "\nDone";
37
38unlink($data_file);
39
40?>
41--EXPECT--
42*** Testing fprintf() with integers ***
43
44-- Iteration 1 --
45
460
471
48-1
492
50-2
5123333333
52-23333333
531234
54-- Iteration 2 --
55
560
571
58-1
592
60-2
6123333333
62-23333333
631234
64-- Iteration 3 --
65
66+0
67+1
68-1
69+2
70-2
71+23333333
72-23333333
73+1234
74-- Iteration 4 --
75
76      0
77      1
78     -1
79      2
80     -2
8123333333
82-23333333
83   1234
84-- Iteration 5 --
85
860
871
88-1
892
90-2
9123333333
92-23333333
931234
94-- Iteration 6 --
95
960000000
970000001
98-000001
990000002
100-000002
10123333333
102-23333333
1030001234
104-- Iteration 7 --
105
1060
1071
108-1
1092
110-2
11123333333
112-23333333
1131234
114-- Iteration 8 --
115
116######0
117######1
118#####-1
119######2
120#####-2
12123333333
122-23333333
123###1234
124Done
125