From 0b59f270a432f8c7b6128981f0a39b4a2e2fbd34 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 13 May 2008 04:22:33 +0000 Subject: Some sweeping syntax changes for consistency: (! foo) changed to ( ! foo) || changed to OR changed newline standardization code in various places from preg_replace to str_replace --- system/helpers/text_helper.php | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'system/helpers/text_helper.php') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index 2d03699f3..18f33d2b3 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -1,4 +1,4 @@ -', $tag_close = '') { @@ -349,19 +349,22 @@ if (! function_exists('highlight_phrase')) * @param integer the number of characters to wrap at * @return string */ -if (! function_exists('word_wrap')) +if ( ! function_exists('word_wrap')) { function word_wrap($str, $charlim = '76') { // Se the character limit - if (! is_numeric($charlim)) + if ( ! is_numeric($charlim)) $charlim = 76; // Reduce multiple spaces $str = preg_replace("| +|", " ", $str); // Standardize newlines - $str = preg_replace("/\r\n|\r/", "\n", $str); + if (strpos($str, "\r") !== FALSE) + { + $str = str_replace(array("\r\n", "\r"), "\n", $str); + } // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. @@ -436,6 +439,6 @@ if (! function_exists('word_wrap')) } } - -/* End of file text_helper.php */ + +/* End of file text_helper.php */ /* Location: ./system/helpers/text_helper.php */ \ No newline at end of file -- cgit v1.2.3-24-g4f1b