Introduction: This is the PHP closure experiment detailed page, introduced and PHP, related knowledge, skills, experience, and some PHP source code and so on.
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);
More articles on "PHP closure experiment"
Love EE focus on Java Michael Jackson Video station JSON online tool
Http://biancheng.dnbcw.info/php/336629.html pageno:10