1--TEST--
2file() on a file with blank lines
3--FILE--
4<?php
5
6$filepath = __FILE__ . ".tmp";
7$fd = fopen($filepath, "w+");
8fwrite($fd, "Line 1\n\n \n  \n\Line 3");
9fclose($fd);
10
11echo "file():\n";
12var_dump(file($filepath));
13
14echo "\nfile() with FILE_IGNORE_NEW_LINES:\n";
15var_dump(file($filepath, FILE_IGNORE_NEW_LINES));
16
17echo "\nfile() with FILE_SKIP_EMPTY_LINES:\n";
18var_dump(file($filepath, FILE_SKIP_EMPTY_LINES));
19
20echo "\nfile() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:\n";
21var_dump(file($filepath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES));
22
23unlink($filepath);
24
25?>
26--EXPECT--
27file():
28array(5) {
29  [0]=>
30  string(7) "Line 1
31"
32  [1]=>
33  string(1) "
34"
35  [2]=>
36  string(2) "
37"
38  [3]=>
39  string(3) "
40"
41  [4]=>
42  string(7) "\Line 3"
43}
44
45file() with FILE_IGNORE_NEW_LINES:
46array(5) {
47  [0]=>
48  string(6) "Line 1"
49  [1]=>
50  string(0) ""
51  [2]=>
52  string(1) " "
53  [3]=>
54  string(2) "  "
55  [4]=>
56  string(7) "\Line 3"
57}
58
59file() with FILE_SKIP_EMPTY_LINES:
60array(5) {
61  [0]=>
62  string(7) "Line 1
63"
64  [1]=>
65  string(1) "
66"
67  [2]=>
68  string(2) "
69"
70  [3]=>
71  string(3) "
72"
73  [4]=>
74  string(7) "\Line 3"
75}
76
77file() with FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES:
78array(4) {
79  [0]=>
80  string(6) "Line 1"
81  [1]=>
82  string(1) " "
83  [2]=>
84  string(2) "  "
85  [3]=>
86  string(7) "\Line 3"
87}
88