可能重複:
PHP templating using custom code replacing using regex使用正則表達式來Smarty的語法轉換爲PHP語法
嗨,
我想
<a href="{$game.url}">{$game.info.cleanname}</a>
轉換爲
<a href="$game['url']">$game['info']['cleanname']</a>
使用的preg_replace
可能重複:
PHP templating using custom code replacing using regex使用正則表達式來Smarty的語法轉換爲PHP語法
嗨,
我想
<a href="{$game.url}">{$game.info.cleanname}</a>
轉換爲
<a href="$game['url']">$game['info']['cleanname']</a>
使用的preg_replace
有一個問題,問昨天如出一轍:
PHP templating using custom code replacing using regex
只需添加一個第二的preg_replace版本(或更多)其他情況相匹配:
preg_replace('/\{\$(\w+)\.(\w+)\}/', '\\$$1[\'$2\']', $src);
如果您需要更多幫助:https://stackoverflow.com/questions/89718/is-there-anything-like-regexbuddy-in-the-open-source-world
問題與標題之間的關係是什麼? – Toto 2011-03-14 16:33:20
你是指'<?php echo $ game ['info'] ['cleanname']; ?>' – 2011-03-14 16:37:19
@mike B是的,它確實涉及到這個問題。該死的你們很快就會倒下。 – Vish 2011-03-14 21:30:37