# 获取家列表 $home_list = Model::home_users()->selectBySql( 'select h.home_id,h.name from home_users as hu left join home as h on hu.home_id = h.home_id where hu.user_id=?' ,[$this->token_info['id']] ); 输出: [ ['home_id'=>'1','count'=>'31'], ['home_id'=>'2','count'=>'24'] ]; # 家的消息数目 $msg = self::readMsg([ 'user_id'=>$this->token_info['id'], 'home_id'=>$homes, 'read_type'=>'r' ]); 返回: [ ['home_id'=>'1','count'=>'31'], ['home_id'=>'2','count'=>'24'] ]; $new = array_map(function($h,$m){ return array_merge($h,$m); },$home_list,$msg); 返回: Array ( [0] => Array ( [home_id] => 1 [home_name] => 家1 [count] => 31 ) [1] => Array ( [home_id] => 2 [home_name] => 家2 [count] => 24 ) )
array_map的多个数组技巧
原创
©著作权归作者所有:来自51CTO博客作者灰色轨迹111的原创作品,请联系作者获取转载授权,否则将追究法律责任
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
java同时处理多个数据
java同时处理多个数据的三种常用方法详解,并提供了详细的代码示例。
java 抛出异常 多线程 -
array_map() 函数
array_map() 函数
函数 array map