From 69aa05376bd6cd04e23b6edcfe0d44e9e5f5f7e2 Mon Sep 17 00:00:00 2001 From: Jim Wigginton Date: Fri, 21 Aug 2009 21:47:19 +0000 Subject: - replaced the drop down menu log filter thing with log searching git-svn-id: file:///svn/phpbb/branches/phpBB-3_0_0@10041 89ea8834-ac86-4346-8a33-228a782c2dd0 --- phpBB/includes/utf/utf_tools.php | 47 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'phpBB/includes/utf/utf_tools.php') diff --git a/phpBB/includes/utf/utf_tools.php b/phpBB/includes/utf/utf_tools.php index 9ee87a5425..6f3ac93305 100644 --- a/phpBB/includes/utf/utf_tools.php +++ b/phpBB/includes/utf/utf_tools.php @@ -1945,4 +1945,51 @@ function utf8_basename($filename) return $filename; } +/** +* UTF8-safe str_replace() function +* +* @param string $search The value to search for +* @param string $replace The replacement string +* @param string $subject The target string +* @return string The resultant string +*/ +function utf8_str_replace($search, $replace, $subject) +{ + if (!is_array($search)) + { + $search = array($search); + if (is_array($replace)) + { + $replace = (string) $replace; + trigger_error('Array to string conversion', E_USER_NOTICE); + } + } + + $length = sizeof($search); + + if (!is_array($replace)) + { + $replace = array_fill(0, $length, $replace); + } + else + { + $replace = array_pad($replace, $length, ''); + } + + for ($i = 0; $i < $length; $i++) + { + $search_length = utf8_strlen($search[$i]); + $replace_length = utf8_strlen($replace[$i]); + + $offset = 0; + while (($start = utf8_strpos($subject, $search[$i], $offset)) !== false) + { + $subject = utf8_substr($subject, 0, $start) . $replace[$i] . utf8_substr($subject, $start + $search_length); + $offset = $start + $replace_length; + } + } + + return $subject; +} + ?> \ No newline at end of file -- cgit v1.2.1