开发者

How can i use php's preg_replace with a simple string and wildcards?

If i have the string [link="*"] where * is a wildcard how could i then use php to replace the string with <a href="*"> where * 开发者_Go百科is the same value as before?

Is preg_replace the best way to do this?

Thanks, any help appreciated!


preg_replace('~\[link="(.*?)"\]~', '<a href="$1">', $text);


$link = '[link="http://www.google.com/"]';
$link = preg_replace('/\[link="(.*)"\]/', '<a href="$1">', $link);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜