Home  >  Article  >  Backend Development  >  preg_replace_callback

preg_replace_callback

WBOY
WBOYOriginal
2016-06-23 13:01:27798browse

<?phpfunction ac($m) {	$acs = array (		'www' => 'world wide web',		'irs' => 'internal revenue service',	    'pdf' => 'portable document format');	//echo $m[0].",".$m[1]."<br/>";		if (isset($acs[$m[1]]))		return $m[1]."(".$acs[$m[1]].")";	else				return $acs[$m[1]];}$text = "wef <aaa>irs</aaa> rawfg <aaa>www</aaa> h <aaa>pdf</aaa> awf";$newtext = preg_replace_callback("/<aaa>(.*)<\/aaa>/U","ac",$text);print_r ($newtext);?>

函数了没的$m[1]改成$m[0]为什么会没有效果?注释那一行验证了他们值是相等的啊


回复讨论(解决方案)

$m[0]的值带标签<aaa>irs</aaa><aaa>www</aaa>

没懂你的意思
$m[0] 与 $m[1] 是不相等的

$m[0]的值带标签<aaa>irs</aaa><aaa>www</aaa>


搜噶!没打出来不代表不存在!多谢!
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn