note 55659 modified in function.mb-ereg-replace by thiago

From: Date: Tue, 06 Oct 2009 14:16:15 +0000
Subject: note 55659 modified in function.mb-ereg-replace by thiago
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-161403@lists.php.net to get a copy of this message
A simple mb_str_ireplace() implementation - a faster (?) replacement for non-regexp multi-byte string replacement: <?php function mb_str_ireplace($co, $naCo, $wCzym) { $wCzymM = mb_strtolower($wCzym); $coM = mb_strtolower($co); $offset = 0; while(!is_bool($poz = mb_strpos($wCzymM, $coM, $offset))) { $offset = $poz + mb_strlen($naCo); $wCzym = mb_substr($wCzym, 0, $poz). $naCo .mb_substr($wCzym, $poz+mb_strlen($co)); $wCzymM = mb_strtolower($wCzym); } return $wCzym; } ?> [thiago - EDITOR NOTE: This function has improvements from d-okumura [aat] fi{dot}kyd[dot]co.jp] --was-- A simple mb_str_ireplace() implementation - a faster (?) replacement for non-regexp multi-byte string replacement: <?php function mb_str_ireplace($co, $naCo, $wCzym) { $wCzymM = mb_strtolower($wCzym); $coM = mb_strtolower($co); $offset = 0; while(($poz = mb_strpos($wCzymM, $coM, $offset)) !== false) { $offset = $poz + mb_strlen($naCo); $wCzym = mb_substr($wCzym, 0, $poz). $naCo .mb_substr($wCzym, $poz+mb_strlen($co)); $wCzymM = mb_strtolower($wCzym); } return $wCzym; } ?> http://php.net/manual/en/function.mb-ereg-replace.php

« previous php.notes (#161403) next »