Re: ereg_replace

From: Date: Wed, 14 Feb 2001 10:05:08 +0000
Subject: Re: ereg_replace
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-39605@lists.php.net to get a copy of this message
>>>>> ""VB" == "Brian V Bonini" <brian@gfx.cncdsl.com> >>>>> writes: > I know you can replace A or B or C with D but can you replace A > with B and C with D exclusively with one call to ereg_replace or > does this need to be done seperately? With ereg_replace it must be done seperately, but if you use preg_replace you can pass it a list of replacements. like this: <?php $string = "this is my string."; print $string . "<br>\n"; $string = preg_replace( array( '/my/', '/string/' ), array( 'your', 'bit of text' ), $string ); print $string . "<br>\n"; ?> The output would be: this is my string. this is your bit of text. -- Robin Vickery................................................. BlueCarrots, 14th Floor, 20 Eastbourne Terrace, London, W2 6LE

« previous php.general (#39605) next »