note 30116 added to ref.strings

From: Date: Thu, 06 Mar 2003 22:49:19 +0000
Subject: note 30116 added to ref.strings
Groups: php.notes 
Request: Send a blank email to php-notes+get-44956@lists.php.net to get a copy of this message
function standardize_eol($s) { /* Return text with Unix end of line conventions. * * Input: $s The string to convert. * * Returns: The string with Unix end of line conventions. * * Side Effects: none */ return strtr(ereg_replace("\r\n", "\n", $s), "\r", "\n"); } To do the same thing to a file: // Copy file, converting // Windoze and mac eol sequences to Unix eol along the way. exec("sed -e 's/\r\$//' $old_path" . ' | tr "\\r" "\\n"' . " > $new_path"); Do _not_ try to set $old_path and $new_path to the same file. Failure will be erratic. -- http://www.php.net/manual/en/ref.strings.php http://master.php.net/manage/user-notes.php?action=edit+30116 http://master.php.net/manage/user-notes.php?action=delete+30116 http://master.php.net/manage/user-notes.php?action=reject+30116

« previous php.notes (#44956) next »