RE: [PHP] Problem with a regex!
| From: | Dustin Butler | Date: | Sun, 28 Jan 2001 04:41:05 +0000 |
| Subject: | RE: [PHP] Problem with a regex! | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-37089@lists.php.net to get a copy of this message | ||
Zack,
Your not going to find {title} when $var = "TITLE". Everything PHP is case
sensitive. Also $string is not changed if there are matches, ereg_replace
returns the modified string.
HTH
Dustin
> I tried ereg_replace("\{" . $var . "\}",$value,$string) and
> it didnt return
> an error... but it didnt replace anything.
> Other ideas ? Either {'s are
> impossible to escape or php just doesnt like me...
>
> --- CC Zona <cczona@nospam.invalid>
> > wrote:
> >In article <20010128011709.78C253ECC@sitemail.everyone.net>,
> >hamoe@sect0r.com (Zack Ham) wrote:
> >
> >> What I'm trying to do is run through it and replace
> {title} with an
> >> appropriate value. I have tried running
> >> ereg_replace("{$var}",$value,$string) and
> >> ereg_replace("\{$var\}",$value,$string). Neither work.
> They either do
> >> nothing or produce the error "Warning: invalid content of \{\}".
> >
> >Is $var=="title" (same case, no leading/trailing whitespace, etc.)?
> >
> >If so, then perhaps try:
> > ereg_replace("\{" . $title . "\}",$value,$string)
> >
> >If not, then perhaps one of these:
> > eregi_replace("\{" . $title . "\}",$value,$string)
> > eregi_replace("\{title\}",$value,$string)