Re: case insensitive str_replace()

From: Date: Mon, 28 Aug 2000 01:13:27 +0000
Subject: Re: case insensitive str_replace()
Groups: php.general 
Request: Send a blank email to php-general+get-13871@lists.php.net to get a copy of this message
Wizaerd wrote:
How could I use str_replace for simple string replacement that is case insensitive? $txtHoldText = str_replace( '[h]', '<H3>', $txtHoldText ); is not the same as $txtHoldText = str_replace( '[H]', '<H3>', $txtHoldText ); I reied using strtolower() on the main text, but then of course the entire content of $txtHoldText is converted to lower case, which is not the desirable effect.
Since you want case-insensitivity, you'll probably need to go with eregi_replace() <?php $txtHoldText = '[h][H]'; print eregi_replace('\[h\]', '<H3>', $txtHoldText); ?> http://www.php.net/manual/html/function.eregi-replace.html Brian

« previous php.general (#13871) next »