RE: [PHP] ereg_replace
| From: | Brian V Bonini | Date: | Wed, 14 Feb 2001 13:50:54 +0000 |
| Subject: | RE: [PHP] ereg_replace | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-39619@lists.php.net to get a copy of this message | ||
That's exactly what I want to do.... Thanks!
> -----Original Message-----
> From: Robin Vickery [mailto:robin@planet-three.co.uk]
> Sent: Wednesday, February 14, 2001 5:05 AM
> To: php-general@lists.php.net
> Subject: Re: [PHP] ereg_replace
>
>
> >>>>> ""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
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>
>