note 113135 added to function.str-ireplace

From: Date: Wed, 04 Sep 2013 03:49:25 +0000
Subject: note 113135 added to function.str-ireplace
Groups: php.notes 
Request: Send a blank email to php-notes+get-196155@lists.php.net to get a copy of this message
As noted by hfuecks, str_ireplace will make your matched values lower case, even if the source was originally Upper case. To prevent this you can use preg_replace() instead: $string = 'The Lord Of The Rings'; $word = 'lord'; echo str_ireplace($word, '<em>'.$word.'</em>', $string); // Returns: The <em>lord</em> Of The Rings echo preg_replace('/('.$word.')/i', '<em>$1</em>', $string); // Returns: The <em>Lord</em> Of The Rings ---- Server IP: 69.147.83.199 Probable Submitter: 114.23.245.158 ---- Manual Page -- http://php.net/manual/en/function.str-ireplace.php Edit -- https://master.php.net/note/edit/113135 Del: integrated -- https://master.php.net/note/delete/113135/integrated Del: useless -- https://master.php.net/note/delete/113135/useless Del: bad code -- https://master.php.net/note/delete/113135/bad+code Del: spam -- https://master.php.net/note/delete/113135/spam Del: non-english -- https://master.php.net/note/delete/113135/non-english Del: in docs -- https://master.php.net/note/delete/113135/in+docs Del: other reasons-- https://master.php.net/note/delete/113135 Reject -- https://master.php.net/note/reject/113135 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#196155) next »