php闭包实验

WBOY
WBOYOriginal
2016-06-23 14:32:50829browse

简介:这是php闭包实验的详细页面,介绍了和php,有关的知识、技巧、经验,和一些php源码等。

class='pingjiaF' frameborder='0' src='http://biancheng.dnbcw.info/pingjia.php?id=336629' scrolling='no'>
class IArray extends ArrayObject  {      	static function make($array)      	{          		return new self($array);      	}	function map($func)      	{          		$res = new self();				foreach ($this as $k => $v)   		{   			$res[$k] = $func($k, $v);          		}		return $res;      	}		function filter($func)      	{          		$res = new self();				foreach ($this as $k => $v)   		{              			if ($func($k, $v))   			{                  				$res[$k] = $v;             			}      		}		return $res;      	}}$nums = array(10,20,30,40);$res = IArray::make($nums)->filter(function($k, $v) { return $v > 15; })->map(function($k, $v) { return $v * 2; });print_r($res);

“php闭包实验”的更多相关文章 》

爱J2EE关注Java迈克尔杰克逊视频站JSON在线工具

http://biancheng.dnbcw.info/php/336629.html pageNo:10
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
Previous article:php开源服务器Next article:PHP缓存检查