Getting all lines is done this way (if you want to catch dos, mac and unix line feeds):
$lines = explode("
", str_replace(array("
", "
"), "
", $string));
Filtering lines with more than one character can be done with preg_grep()
:
$lines = preg_grep( /^.{2}/ , $lines);
Or using regular expressions for the complete process:
preg_match_all( /^.{2}.*$/ , $string, $matches);
$lines = $matches[0];
Or if you don t need an array containing all remaining lines, you can remove the unwanted strings with a single call:
$string = preg_replace( /^.?$
/m , , $string);