标签:pre for 循环 tar func int map php ack
过滤
//筛选奇数 function test_odd($var) { return ($var & 1); } $a1=array("a","b",2,3,4,43,21); print_r(array_filter($a1,"test_odd"));
循环操作
$start=time(); $a=[[‘name‘=>‘jack‘,‘age‘=>22],[‘name‘=>‘rose‘,‘age‘=>12]]; $res=array_map(function ($s){return $s[‘age‘];},$a); print_r(time()-$start); print_r($res); //说明此种方式要比foreach更节约时间
标签:pre for 循环 tar func int map php ack
原文地址:https://www.cnblogs.com/huay/p/11447258.html