RE: [PHP] Re: Remove cahracters in string
| From: | Rick Fletcher | Date: | Mon, 10 May 2004 21:09:53 +0000 |
| Subject: | RE: [PHP] Re: Remove cahracters in string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-185866@lists.php.net to get a copy of this message | ||
> > > Below is string let's name it A.
> > >
> ttttttttttttttttttttttttttPhiladelphiaFirstadate05Oct2004ttttttttttt
> > > ttt
> > >
> > > I want to get string B. That looks like
> > > PhiladelphiaFirstadate05Oct2004
> > >
> > > No characters before Philadelphia and after 20004
> >
> >Is the character you want to remove ('t') always the same?
> >
> No. It just an example
An accurate example of what you're actually going to be doing would help.
For this example I would have suggested:
<?php
$str = "ttttttttPhiladelphiaFirstadate05Oct2004tttttttt";
$str = trim( $str, "t" );
print( $str ); // outputs "PhiladelphiaFirstadate05Oct2004"
?>
Cheers,
Rick