我建立一個模板系統收發郵件,目前工作在格式人:循環通過自定義模板掛鉤的事情
$array['key1'] = "text";
$array['key2'] = "more text";
<!--key1--> // replaced with *text*
<!--key2--> // replaced with *more text*
對於這個特殊的項目,我有這種結構的嵌套數組:
$array['object1']['nest1']['key1'] = "text";
$array['object2']['next1']['key1'] = "more text";
<!--[object1][nest1][key1]--> // replaced with *text*
<!--[object2][nest1][key1]--> // replaced with *more text*
<!-- .. -->
將放置在HTML文件中,然後將其加載到一個字符串中。最上面的例子顯示我用數據替換註釋。
在PHP中這樣做的最好方法是什麼?我想我可以通過陣列循環,但後來我失去了思路,迷失在我正在做的事情中!
所有幫助將不勝感激! 謝謝
那麼,你想用數組中的內容替換字符串中類似數組的部分? – 2010-05-01 12:46:00
是啊...它的更多的模板引擎 – tarnfeld 2010-05-01 13:02:24
可能重複的http://stackoverflow.com/questions/2171963/php-array-as-variable-name – outis 2010-05-01 13:21:33