I finally got something to do it, at least, in inline code.
I couldn't figure out how to remove NULLS, anybody know? A search on:
http://marc.theaimsgroup.com/?l=php-general&r=1&w=2
didn't turn anything up.
//====================================================================
// WORKING CODE FOR R-E-A-L-L-Y cleaning up a string, converting line
ends
// to *nix, allows two \n's in a row for paragraphs.
// note, the perios in the echo statements show absence/presence of
// ending white space
//====================================================================
<?PHP
$bad_str = " \t\t\t\\r\\\r\r\r\r\n\r\nFour
schore ...........and seven \n\n\n\n\nr\r\r\rn\r years
ago, ,,,,,,, ,,,,,,,our father created on tis planet
\t\t\t\\r\\\r\r\r\r\n\r\nFour ";
echo( "\nuncleaned
string----------------------------------------------------------------------\n");
echo($bad_str );
echo( ".\ncleaned
string---------------------------------------------------------------------------\n");
$bad_str = str_replace( "\x0D\x0A", "\x0A", $bad_str );
$bad_str = str_replace( "\x0D" , "\x0A", $bad_str );
$bad_str = ereg_replace( "\x0A\x0A+", "\x0A\x0A" , $bad_str
); // compresses run on line ends to double line ends
$bad_str = ereg_replace( "[\x01-\x09]", " " , $bad_str );
$bad_str = ereg_replace( "[\x0B-\x1F]", " " , $bad_str );
$bad_str = ereg_replace( " +" , " " , $bad_str ); //
compresses run on spaces to a single space
$bad_str = trim( $bad_str );
echo( $bad_str );
echo(".</pre>\n");
?>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php