diff options
author | Andrey Andreev <narf@devilix.net> | 2014-05-20 10:39:06 +0200 |
---|---|---|
committer | Andrey Andreev <narf@devilix.net> | 2014-05-20 10:39:06 +0200 |
commit | bcd237e0044d950c0bc3e559b34d3c1b8ea51deb (patch) | |
tree | 089b9456a43a0035fd98e8fac7283678daaea76c /system/helpers/text_helper.php | |
parent | 69c56441df49280cb79c67b80ecafa4f52e4453f (diff) | |
parent | f0ab81362bb7732ac1a4272e950c5b6cea59bb06 (diff) |
Merge pull request #3058 from vlakoff/word_wrap
Fixes in word_wrap() functions
Diffstat (limited to 'system/helpers/text_helper.php')
-rw-r--r-- | system/helpers/text_helper.php | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index ca19ab98b..1d0605ddc 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -430,12 +430,12 @@ if ( ! function_exists('word_wrap')) // If the current word is surrounded by {unwrap} tags we'll // strip the entire chunk and replace it with a marker. $unwrap = array(); - if (preg_match_all('|(\{unwrap\}.+?\{/unwrap\})|s', $str, $matches)) + if (preg_match_all('|\{unwrap\}(.+?)\{/unwrap\}|s', $str, $matches)) { for ($i = 0, $c = count($matches[0]); $i < $c; $i++) { $unwrap[] = $matches[1][$i]; - $str = str_replace($matches[1][$i], '{{unwrapped'.$i.'}}', $str); + $str = str_replace($matches[0][$i], '{{unwrapped'.$i.'}}', $str); } } @@ -460,7 +460,7 @@ if ( ! function_exists('word_wrap')) while (mb_strlen($line) > $charlim) { // If the over-length word is a URL we won't wrap it - if (preg_match('!\[url.+\]|://|wwww.!', $line)) + if (preg_match('!\[url.+\]|://|www\.!', $line)) { break; } @@ -491,8 +491,7 @@ if ( ! function_exists('word_wrap')) } } - // Remove the unwrap tags and return - return str_replace(array('{unwrap}', '{/unwrap}'), '', $output); + return $output; } } |