> >It'd be easier to use a regular expression for something like this.
> >Something like this would work (from PHP Architect):
> >
> >$s = "I am going to be {a} years old on the {b}th of November, {c}.";
> >$a = array(
> >"a" => "one hundred",
> >"b" => "seventeen",
> >"c" => "two thousand two");
> >$z = preg_replace("/\{([a-z]+)\}/e","\$a['$1']",$s);
> >echo $z;
> >Output:
> >I am going to be one hundred years old on the seventeenth of
November,
> >two thousand two.
> 
> Now that I've been shown what you meant, and had a chance to play with
it,
> I can see that it's not really going to work out for me. The reason
is, I
> don't know in advance what the contents of the [] will be.

Okay, so how do you know what to replace something like [author] with?
What exactly are you doing again? I've forgotten the original question.
:)

I'm sure there is a better, faster way to do it with regular expressions
or something similar that going digit by digit and looking for [ and ],
etc...

---John W. Holmes...

PHP Architect - A monthly magazine for PHP Professionals. Get your copy
today. http://www.phparch.com/



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to