|
Posted by Alan Little on 05/20/06 18:12
Carved in mystic runes upon the very living rock, the last words of
Dikkie Dik of comp.lang.php make plain:
>> For example:
>>
>> $this->animal = 'lamb';
>> $this->string = 'Mary had a little {{animal}}';
>>
>> The goal is to extract 'animal' from the string (no problem), convert
>> it to 'lamb' and replace it in the string (again, no problem). The
>> question is, if I have 'animal', how do I get 'lamb'? In global
>> space, I would simply have 'animal' in a variable, and use $$var to
>> get 'lamb'.
>
> Ah. Why not use str_replace?
The replacing part is not a problem.
> And when you are using classes, you could as easily define a Variable
> class with a Name and a Value method, and even a ToTemplate method
> that puts the two pairs of curly braces around them.
I'm not sure I follow you here. I'm trying to get value names *from* a
string, and then get the values for those names.
> If this is for a template engine, you probably have the name/value
> pairs in a "named" array.
For some values, yes. But in other cases, such as error reporting, I need
to access an actual variable.
Anyway, I have it worked out now. But thank you for answering.
--
Alan Little
Phorm PHP Form Processor
http://www.phorm.com/
Navigation:
[Reply to this message]
|