【发布时间】:2012-01-13 05:12:28
【问题描述】:
我需要一个函数,用正确的变量替换“{}”中的每个变量名。 像这样的:
$data["name"] = "Johnny";
$data["age"] = "20";
$string = "Hello my name is {name} and I'm {age} years old.";
$output = replace($string, $data);
echo $output;
//outputs: Hello my name is Johnny and I'm 20 years old.
我知道为此有框架/引擎,但我不想为此安装一堆文件。
【问题讨论】:
标签: php