Re: [PHP-DEV] python dictionary-like % (percent) substitution in php (was: Good idea in % (percent) substitutions in string) From: Zeev Suraski (zeev <email protected>)
Date: 08/28/01

At 16:35 28-08-01, Jo Giraerts wrote:
>This is already possible in php, though with the following simple
>function..
>
> // function to read a file with php-vars in as a string
> // $predefined_vars: an array ("varname" => "value"). all the
> // variablenames defined in this array can be used in the bodyfile.
> // They will receive the respective values. This makes personalising
> // the mailes easier..
> function file_as_body($filename, $predefined_vars)
> {
> $ar = file($filename);
> extract($predefined_vars);
>
> foreach ($ar as $number => $line)
> {
> eval("\$ar2[] = \"$line\";");

Yikes, is there any reason that's not simply $ar2[] = $line;?

Anyway, how does it give the same functionality as the suggest aprintf()?

Zeev

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>