后端开发|php教程
PHP,二维数组,数组合并
后端开发-php教程
游戏app源码下载,vscode怎么用谷歌打开,ubuntu调时间,解决tomcat不停重启,爬虫taptap榜单,php 查询一条记录,好的seo系统加盟代理项目,情感测试类网站源码,人力资源htm模板lzw
例子:
java cms建站系统源码,vscode用哪种语言比较好,多显卡ubuntu,Tomcat算Java的吗,招聘 pytho爬虫,php函数记忆卡,武汉抖音seo搜索优化排名lzw
array(3) { [0]=> array(16) { ["id"]=> string(2) "42" ["uid"]=> string(2) "14" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1443927600" ["createtime"]=> string(10) "1443880619" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月04日" ["date"]=> string(6) "周日" ["uname"]=> NULL ["album"]=> string(0) "" } [1]=> array(16) { ["id"]=> string(2) "40" ["uid"]=> string(2) "14" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1444359600" ["createtime"]=> string(10) "1444268595" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月09日" ["date"]=> string(6) "周五" ["uname"]=> NULL ["album"]=> string(0) "" } [2]=> array(16) { ["id"]=> string(2) "43" ["uid"]=> string(1) "2" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1444359620" ["createtime"]=> string(10) "1444268595" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月09日" ["date"]=> string(6) "周五" ["uname"]=> NULL ["album"]=> string(0) "" }}
现在想要对这个二维数组下的元素,time相同的合并到同一数组下。想要的效果为:
极铺 源码,vscode搜索整个文件夹,ubuntu修复dpkg,tomcat集群怎么制作,python爬虫报价,php 一句话 安全狗,南阳seo推广工作室招聘,图片分享网站源码 codeigniterlzw
array(2) { ["10月04日"]=> array(1) { [0]=> array(16) { ["id"]=> string(2) "42" ["uid"]=> string(2) "14" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1443927600" ["createtime"]=> string(10) "1443880619" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月04日" ["date"]=> string(6) "周日" ["uname"]=> NULL ["album"]=> string(0) "" } } ["10月09日"]=> array(2) { [0]=> array(16) { ["id"]=> string(2) "40" ["uid"]=> string(2) "14" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1444359600" ["createtime"]=> string(10) "1444268595" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月09日" ["date"]=> string(6) "周五" ["uname"]=> NULL ["album"]=> string(0) "" } [1]=> array(16) { ["id"]=> string(2) "43" ["uid"]=> string(1) "2" ["euid"]=> string(2) "56" ["did"]=> string(1) "1" ["nid"]=> string(1) "0" ["phonetime"]=> string(10) "1444359620" ["createtime"]=> string(10) "1444268595" ["type"]=> string(1) "3" ["status"]=> string(1) "0" ["atype"]=> string(1) "1" ["mtype"]=> string(1) "2" ["endtime"]=> string(1) "0" ["time"]=> string(10) "10月09日" ["date"]=> string(6) "周五" ["uname"]=> NULL ["album"]=> string(0) "" } }}
那么。。。代码很简单,没有想象的那么复杂,想要的结果是个三维数组
$result 为原二维数组
$res = array(); //想要的结果foreach ($result as $k => $v) { $res[$v[ ime]][] = $v;}
如果觉得《PHP将二维数组某一个字段相同的数组合并起来办法【PHP】》对你有帮助,请点赞、收藏,并留下你的观点哦!