note 103792 added to function.str-replace

From: Date: Tue, 03 May 2011 23:22:33 +0000
Subject: note 103792 added to function.str-replace
Groups: php.notes 
Request: Send a blank email to php-notes+get-179393@lists.php.net to get a copy of this message
Thanks to mevdschee 29-Jan-2011 11:19 for the implementation of the original search_replace. I added the same function to replace str_ireplace and added the optional $count Argument. <?php function str_ireplace_fixed ($search, $replace, $subject, & $count = 0) { $search = array_map('strtolower',$search); $e = '/('.implode('|',array_map('preg_quote', $search)).')/i'; $replace = array_combine($search, $replace); return preg_replace_callback($e, function($v) use ($search, $replace) { return $replace[strtolower($v[1])]; }, $subject, -1, $count); } function str_replace_fixed ($search, $replace, $subject, & $count = 0) { $e = '/('.implode('|',array_map('preg_quote', $search)).')/'; $replace = array_combine($search, $replace); return preg_replace_callback($e, function($v) use ($search, $replace) { return $replace[$v[1]]; }, $subject, -1, $count); } ---- Server IP: 69.147.83.197 Probable Submitter: 87.185.130.132 ---- Manual Page -- http://www.php.net/manual/en/function.str-replace.php Edit -- https://master.php.net/note/edit/103792 Del: integrated -- https://master.php.net/note/delete/103792/integrated Del: useless -- https://master.php.net/note/delete/103792/useless Del: bad code -- https://master.php.net/note/delete/103792/bad+code Del: spam -- https://master.php.net/note/delete/103792/spam Del: non-english -- https://master.php.net/note/delete/103792/non-english Del: in docs -- https://master.php.net/note/delete/103792/in+docs Del: other reasons-- https://master.php.net/note/delete/103792 Reject -- https://master.php.net/note/reject/103792 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#179393) next »