note 91810 added to ref.mbstring

From: Date: Fri, 26 Jun 2009 12:46:32 +0000
Subject: note 91810 added to ref.mbstring
Groups: php.notes 
Request: Send a blank email to php-notes+get-157525@lists.php.net to get a copy of this message
I hope this mb_str_replace will work for arrays. Please use mb_internal_encoding() beforehand, if you need to change the encoding. Thanks to marc at ermshaus dot org for the original. <?php if(!function_exists('mb_str_replace')) { function mb_str_replace($search, $replace, $subject) { if(is_array($subject)) { $ret = array(); foreach($subject as $key => $val) { $ret[$key] = mb_str_replace($search, $replace, $val); } return $ret; } foreach((array) $search as $key => $s) { if($s == '') { continue; } $r = !is_array($replace) ? $replace : (array_key_exists($key, $replace) ? $replace[$key] : ''); $pos = mb_strpos($subject, $s); while($pos !== false) { $subject = mb_substr($subject, 0, $pos) . $r . mb_substr($subject, $pos + mb_strlen($s)); $pos = mb_strpos($subject, $s, $pos + mb_strlen($r)); } } return $subject; } } ?> ---- Server IP: 194.153.94.10 Probable Submitter: 219.118.191.50 ---- Manual Page -- http://www.php.net/manual/en/ref.mbstring.php Edit -- https://master.php.net/note/edit/91810 Del: integrated -- https://master.php.net/note/delete/91810/integrated Del: useless -- https://master.php.net/note/delete/91810/useless Del: bad code -- https://master.php.net/note/delete/91810/bad+code Del: spam -- https://master.php.net/note/delete/91810/spam Del: non-english -- https://master.php.net/note/delete/91810/non-english Del: in docs -- https://master.php.net/note/delete/91810/in+docs Del: other reasons-- https://master.php.net/note/delete/91810 Reject -- https://master.php.net/note/reject/91810 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#157525) next »