RE: [PHP] Removing a string (located within one field) from the c ontents of another string within another field

From: Date: Fri, 18 Oct 2002 15:23:54 +0000
Subject: RE: [PHP] Removing a string (located within one field) from the c ontents of another string within another field
Groups: php.general 
Request: Send a blank email to php-general+get-120521@lists.php.net to get a copy of this message
Hi, > > What is the most straight forward method of removing a > > string (located within one field) from the contents of > > another string within another field?? > > Example: > > [FIELD1] ="klmnop" > > [FIELD2]="blah blah blah klmnop blah blah blah" > > End result for FIELD2 should be: "blah blah blah blah blah blah" > > look at ereg_replace() > $newstr = ereg_replace($field1, NULL, $field2); Invoking the regex parser to do a simple string substitution is complete overkill. Look into str_replace() instead, it's a lot cheaper: http://www.php.net/manual/en/function.str-replace.php Cheers Jon

« previous php.general (#120521) next »