1--TEST-- 2Test fprintf() function (variation - 9) 3--FILE-- 4<?php 5 6$string_variation = array( "%5s", "%-5s", "%05s", "%'#5s" ); 7$strings = array( NULL, "abc", 'aaa' ); 8 9/* creating dumping file */ 10$data_file = __DIR__ . '/fprintf_variation_009.txt'; 11if (!($fp = fopen($data_file, 'wt'))) 12 return; 13 14$counter = 1; 15/* string type variations */ 16fprintf($fp, "\n*** Testing fprintf() for string types ***\n"); 17foreach( $string_variation as $string_var ) { 18 fprintf( $fp, "\n-- Iteration %d --\n",$counter); 19 foreach( $strings as $str ) { 20 fprintf( $fp, "\n"); 21 fprintf( $fp, $string_var, $str ); 22 } 23 $counter++; 24} 25 26fclose($fp); 27 28print_r(file_get_contents($data_file)); 29echo "\nDone"; 30 31unlink($data_file); 32 33?> 34--EXPECT-- 35*** Testing fprintf() for string types *** 36 37-- Iteration 1 -- 38 39 40 abc 41 aaa 42-- Iteration 2 -- 43 44 45abc 46aaa 47-- Iteration 3 -- 48 4900000 5000abc 5100aaa 52-- Iteration 4 -- 53 54##### 55##abc 56##aaa 57Done 58