if I have a file that contains something like this
"
text text text
(possibly some spaces here)
text text text
text text text
text text text
(no spaces)
text text text text text text
(no spaces)
text text text
"
and I save the file as an array:
$contents = file("document.txt");
now do I make a new array that does not include any of the blank lines?
detecting lines without anything on them
Moderator: General Moderators
-
jaymoore_299
- Forum Contributor
- Posts: 128
- Joined: Wed May 11, 2005 6:40 pm
- Contact:
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
Code: Select all
$file = file('document.txt');
$empty = array();
for ($x=0; $x <= count($file); $x++) {
if (!empty($file[$x]))
echo $file[$x];
else
$empty[] = $x;
}
foreach ($empty as $line) {
echo 'line #'.$line.' was empty <br />';
}