Re: python dictionary-like % (percent) substitution in php (was: Good idea in % (percent) substitutions in string)
| From: | Zeev Suraski | Date: | Tue, 28 Aug 2001 13:41:45 +0000 |
| Subject: | Re: python dictionary-like % (percent) substitution in php (was: Good idea in % (percent) substitutions in string) | ||
| References: | 1 2 | Groups: | php.dev |
| Request: | Send a blank email to php-dev+get-64514@lists.php.net to get a copy of this message | ||
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) {Yikes, is there any reason that's not simply $ar2[] = $line;? Anyway, how does it give the same functionality as the suggest aprintf()? Zeev$ar = file($filename); extract($predefined_vars);foreach ($ar as $number => $line) { eval("\$ar2[] = \"$line\";");