Private/Polyfony/Format.php
public static function wrap($text, $phrase, $wrapper = '<strong class="highlight">\\1</strong>') {
		if(empty($text)) {
			return '';
		}
		if(empty($phrase)) {
			return $text;
		}
		if(is_array($phrase)) {
			foreach ($phrase as $word) {
				$pattern[] = '/(' . preg_quote($word, '/') . ')/i';
				$replacement[] = $wrapper;
			}
		}
		else {
			$pattern = '/('.preg_quote($phrase, '/').')/i';
			$replacement = $wrapper;
		}
		return preg_replace($pattern, $replacement, $text);
	}
public static function wrap($text, $phrase, $wrapper = '<strong class="highlight">\\1</strong>') {
		if(empty($text)) {
			return '';
		}
		if(empty($phrase)) {
			return $text;
		}
		if(is_array($phrase)) {
			foreach ($phrase as $word) {
				$pattern[] = '/(' . preg_quote($word, '/') . ')/i';
				$replacement[] = $wrapper;
			}
		}
		else {
			$pattern = '/('.preg_quote($phrase, '/').')/i';
			$replacement = $wrapper;
		}
		return preg_replace($pattern, $replacement, $text);
	}
public static function wrap ( $ text , $ phrase , $ wrapper = '<strong class="highlight">\\1</strong>' ) { if ( empty ( $ text ) ) { return '' ; } if ( empty ( $ phrase ) ) { return $ text ; } if ( is_array ( $ phrase ) ) { foreach ( $ phrase as $ word ) { $ pattern [ ] = '/(' . preg_quote ( $ word , '/' ) . ')/i' ; $ replacement [ ] = $ wrapper ; } } else { $ pattern = '/(' . preg_quote ( $ phrase , '/' ) . ')/i' ; $ replacement = $ wrapper ; } return preg_replace ( $ pattern , $ replacement , $ text ) ; }
will wrap a portion of text in another
will wrap a portion of text in another