Hello all,
I want to process an html file.
I want to transfer it to a regular text file so I first have to remove all tags and then to remove all blank lines in the file.
$file=implode('|', file ($path));
$fileArr = strip_tags($file);
well, this remove all tags and creats a string out of the file with | as the delimiter.
before I turn it into a string I want to remove all blank line on the file.
do I need to use array_filter?
if so how?
Thanks
remove empty elements from array
Moderator: General Moderators
e.g.
Code: Select all
<?php
// an example array
$file = array("a\n\r", "\n\r", "\n\r", "b\n\r");
// remove linebreaks
$file = array_map('trim', $file);
// empty strings evaluate to FALSE, so there's no need for any test-function
$file = array_filter($file);
print_r($file);
?>