note 109940 deleted from function.mb-ereg-replace by danbrown

From: Date: Tue, 04 Sep 2012 14:23:31 +0000
Subject: note 109940 deleted from function.mb-ereg-replace by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-190481@lists.php.net to get a copy of this message
Note Submitter: Mr HelloWorld ---- New edition of mb_str_ireplace, code: function mb_str_ireplace($search, $replace, $subject, $encoding = 'UTF-8') { $subject_ch = mb_strtolower($subject, $encoding); $replace_ch = mb_strtolower($search, $encoding); $offset = 0; while(($poz = mb_strpos($subject_ch, $replace_ch, $offset, $encoding)) !== false){ $offset = $poz + mb_strlen($replace, $encoding); $subject = mb_substr($subject, 0, $poz, $encoding).$replace.mb_substr($subject, $poz+mb_strlen($search, $encoding), mb_strlen($subject, $encoding), $encoding); $subject_ch = mb_strtolower($subject, $encoding); } return $subject; }

« previous php.notes (#190481) next »