preg_replace_callback

WBOY
Release: 2016-06-23 13:01:27
Original
799 people have browsed it

<?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);?>
Copy after login

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


回复讨论(解决方案)

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

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

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


搜噶!没打出来不代表不存在!多谢!
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template