replacing strings... (hope it isn't too basic...)

From: Date: Fri, 25 Jul 2003 11:21:00 +0000
Subject: replacing strings... (hope it isn't too basic...)
References: 1 2 3  Groups: php.windows 
Request: Send a blank email to php-windows+get-20901@lists.php.net to get a copy of this message
Q1 :If I'm for example is going to replace all occurences of "foo" in the following sentence with "bar" in case-insensetiv manner how would I do it? "Foo foo foo Foo fOO fOo" should be replaced with "Bar bar bar Bar bAR bAr"... I guess I would need regular expressions? Right? ----------------- Q2: I belive that there will be no cases with "fOO" or "fOo" only "Foo" or "foo". What I'm doing right now is a str_replace(strtolower("FOO"),uc_first(strtolower("BAR")),$myVar_str); This works okey most of the time, but the format from Q1 would be prefered. Would I suffer a great deal of speed trying to fix the above output? ----------------- Q3: Would it work to do a str_replace("foo","foobar","foo foo foo foo foo"); ----------------- Q4: Is ther a predefined function for inserting a string into another string at n characters? $myVar_str = "My bar string"; str_insert("foo",$myVar_str, 3); would result in $myVar_str == My foobar string. I couldn't find this in the manual.... ----------------- .b dev@elstudion.com

« previous php.windows (#20901) next »