When was str_ireplace() added?
Posted: Fri Sep 23, 2005 7:37 pm
I have 4.3.11 and I'm getting 'call to undefined function' when I try to use it.
Edit: hah. vim at least thinks it's valid.
Edit: hah. vim at least thinks it's valid.
A community of PHP developers offering assistance, advice, discussion, and friendship.
http://forums.devnetwork.net/
str_ireplace() wrote:str_ireplace
(PHP 5)
str_ireplace -- Case-insensitive version of str_replace().
Code: Select all
function str_ireplace($search, $replace, $subject) //ignore count parameter, we obviously don't have PHP 5
{
return str_replace ( strlower($search), strlower($replace), strlower($search) );
}Code: Select all
if(!function_exists('str_ireplace')) {
function str_ireplace($search, $replace, $subject, &$count = false) {
if(!is_array($search)) {
$search = array($search);
}
if(!is_array($replace)) {
$replace = array($replace);
}
$search = array_map(CreateFunction('$a','return \'#\'.preg_quote($a,\'#\').\'#i\';'),$search);
return preg_replace($search,$replace,$subject,-1,$count);
}
}