RE: [PHP] Problem with a regex!

2001-01-29 Thread Zack Ham

Thanks a lot.  I knew that, but last night I was just really tired :).  I wasn't 
actually copy-pasting the code I had, so what I had at the time was correct as for 
case.  As for assigning the ereg_replace to a variable, I figured that out about 20 
minutes after i sent out my last mail last night (then I went into deep depression 
realizing how stupid of a mistake it was).  Thanks for all your help {everyone who 
helped}

--- Dustin Butler [EMAIL PROTECTED]
 wrote:
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 [EMAIL PROTECTED]
  wrote:
 In article [EMAIL PROTECTED], 
 [EMAIL PROTECTED] (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)

_
Free email provided by --- http://sect0r.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




[PHP] Problem with a regex!

2001-01-27 Thread Zack Ham

I'm trying to create a small template parser so I can fill my html pages up with data. 
 An example:  htmlheadtitle{title}/title/head/html

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 \{\}".

Any help would be appreciated,
Zack

_
Free email provided by --- http://sect0r.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Problem with a regex!

2001-01-27 Thread Zack Ham

I had it echo off the value of $var right before it ran the ereg_replace and it echoed 
"TITLE".  So there is a value... any ideas on fixing?

--- Julian Wood [EMAIL PROTECTED]
 wrote:

Why not use the php mechanism itself? An easy way to do a template system is
make a normal php page as a template, and then include it from another page
after specifying a bunch of variables.

eg.

template.php:
=

htmlheadtitle?= $title ?/title/head/html

calling page:
=

?php

$title = "My template system";
include ('template.php');

?

Hope this helps,

Julian

on 1/27/01 6:17 PM, Zack Ham at [EMAIL PROTECTED] wrote:

 
 I'm trying to create a small template parser so I can fill my html pages up
 with data.  An example:  htmlheadtitle{title}/title/head/html
 
 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 \{\}".
 
 Any help would be appreciated,
 Zack
 
 _
 Free email provided by --- http://sect0r.com

--
Julian Wood
Learning Technologies and Digital Media
University of Calgary



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

_
Free email provided by --- http://sect0r.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP] Problem with a regex!

2001-01-27 Thread Zack Ham

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 [EMAIL PROTECTED]
 wrote:
In article [EMAIL PROTECTED], 
[EMAIL PROTECTED] (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)

-- 
CC

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

_
Free email provided by --- http://sect0r.com

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]