ze1d Posted December 10, 2007 Share Posted December 10, 2007 Hi all,I'm using preg_replace function to replace a part of string with another in my whole string for the first 2 occurances.. but this function is not working if my string was like this:$string = "SEARCH the web";I mean it dosen't ignore case .. so that it will not change the word "SEARCH" if i used "search" to replace it..is there anyway to do this??Thanks,zeid Link to comment Share on other sites More sharing options...
zppblood Posted December 10, 2007 Share Posted December 10, 2007 If I understand right, are you using regular expressions? You can try using str_ireplace(). Link to comment Share on other sites More sharing options...
ze1d Posted December 10, 2007 Author Share Posted December 10, 2007 I tried that but it keeps giving me this error:Fatal error: Only variables can be passed by reference in ..this is what i wrote $tempstr = str_ireplace($value, "<b>".$value."</b>", $title, 1); Link to comment Share on other sites More sharing options...
justsomeguy Posted December 10, 2007 Share Posted December 10, 2007 There's a pattern modifier you can use with preg_replace that will ignore case.http://www.php.net/manual/en/reference.pcr...n.modifiers.php Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.