【发布时间】:2015-03-30 07:30:48
【问题描述】:
我正在使用preg_replace 查找BBCODE 并将其替换为HTML 代码,
但是在这样做的时候,我需要base64encode url,我该怎么做?
我正在像这样使用preg_replace:
<?php
$bbcode = array('#\[url=(.+)](.+)\[/url\]#Usi');
$html = array('<a href="$1">$2</a>');
$text = preg_replace($bbcode, $html,$text);
我怎样才能base64encodehref 值,即$1?
我试过了:
$html = array('<a href="/url/'.base64_encode('{$1}').'/">$2</a>');
但它的编码是{$1},而不是实际的链接。
【问题讨论】:
-
你试过base64_encode($1)吗? $html = array('$2');
-
@WahyuKodar 仍然无法正常工作,谢谢
标签: php base64 preg-replace encode