Home > Backend Development > PHP Tutorial > 为啥回调函数在array_filter()里面没有起作用

为啥回调函数在array_filter()里面没有起作用

WBOY
Release: 2016-06-13 12:34:27
Original
1190 people have browsed it

为什么回调函数在array_filter()里面没有起作用?

<br />
	<?php<br />
		function myFunction($v) <br />
		{<br />
		if ($v==="Dog")<br />
			{<br />
				return "Fido";<br />
			}<br />
				return $v;<br />
		}<br />
		$a=array("Horse","Dog","Cat");<br />
		//Array ( [0] => Horse [1] => Fido [2] => Cat ) <br />
		print_r(array_map("myFunction",$a)); <br />
		<br />
		//Array ( [0] => Horse [1] => Dog [2] => Cat )<br />
		//为什么回调函数在array_filter()里面没有起作用?<br />
		print_r(array_filter($a,"myFunction"));<br />
	 ?><br />
Copy after login
array_filter() 回调函数

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