From ac023e10e7d9e4ad11783ff7e1154d2701a1ec18 Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Tue, 7 Jan 2014 16:13:03 +0200 Subject: Change Text helper default tag from to Supersedes PR #1497 --- system/helpers/text_helper.php | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) (limited to 'system/helpers') diff --git a/system/helpers/text_helper.php b/system/helpers/text_helper.php index b2351db95..c6d14784b 100644 --- a/system/helpers/text_helper.php +++ b/system/helpers/text_helper.php @@ -329,25 +329,17 @@ if ( ! function_exists('highlight_phrase')) * * Highlights a phrase within a text string * - * @param string the text string - * @param string the phrase you'd like to highlight - * @param string the openging tag to precede the phrase with - * @param string the closing tag to end the phrase with + * @param string $str the text string + * @param string $phrase the phrase you'd like to highlight + * @param string $tag_open the openging tag to precede the phrase with + * @param string $tag_close the closing tag to end the phrase with * @return string */ - function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '') + function highlight_phrase($str, $phrase, $tag_open = '', $tag_close = '') { - if ($str === '') - { - return ''; - } - - if ($phrase !== '') - { - return preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open.'\\1'.$tag_close, $str); - } - - return $str; + return ($str !== '' && $phrase !== '') + ? preg_replace('/('.preg_quote($phrase, '/').')/i', $tag_open.'\\1'.$tag_close, $str) + : $str; } } -- cgit v1.2.3-24-g4f1b