php数组按value分组,PHP – 按键值对多维数组进行分组

我目前有这个代码:

$files = glob('songs/*.{mp3}', GLOB_BRACE);

$dateUploaded = array();

foreach($files as $file){

$path_parts = pathinfo($file);

$dateUploaded[] = array("Date Uploaded" => date ("jS \of F, Y", filemtime($file)), "File Name" => $path_parts['filename']);

}

print_r($dateUploaded);

哪个输出

Array (

[0] => Array (

[Date Uploaded] => 26th of February, 2013

[File Name] => All That Glitters - This Sound (Felix Cartal Remix)

)

[1] => Array (

[Date Uploaded] => 26th of February, 2013

[File Name] => Bertie Blackman - Hide and Seek

)

[2] => Array (

[Date Uploaded] => 18th of December, 2012

[File Name] => Birds of Tokyo - This Fire

)

[3] => Array (

[Date Uploaded] => 18th of December, 2012

[File Name] => Bloc Party - Truth

)

[4] => Array (

[Date Uploaded] => 18th of December, 2012

[File Name] => C2C - Down the Road

)

[5] => Array (

[Date Uploaded] => 18th of December, 2012

[File Name] => Chance Waters - Young and Dumb feat Bertie Blackman

)

[6] => Array (

[Date Uploaded] => 26th of February, 2013

[File Name] => City Calm Down - Sense of Self

)

[7] => Array (

[Date Uploaded] => 18th of December, 2012

[File Name] => Clubfeet - Heartbreak

)

[8] => Array (

[Date Uploaded] => 26th of February, 2013

[File Name] => Cosmo Jarvis - My Own Thing

)

[9] => Array (

[Date Uploaded] => 6th of June, 2013

[File Name] => Courtney Barnett - History Eraser

)

[10] => Array (

[Date Uploaded] => 6th of June, 2013

[File Name] => Delphic - Baiya

)

)

我想要做的是通过“Date Uploaded”键对它们进行分组.所以我有类似的东西:

Array (

[26th of February, 2013] => Array (

[0] All That Glitters - This Sound (Felix Cartal Remix)

[1] Bertie Blackman - Hide and Seek

[2] City Calm Down - Sense of Self

[3] Cosmo Jarvis - My Own Thing

)

[18th of December, 2012] => Array (

[0] Birds of Tokyo - This Fire

[1] Bloc Party - Truth

[2] C2C - Down the Road

[3] Chance Waters - Young and Dumb feat Bertie Blackman

[4] Clubfeet - Heartbreak

)

[6th of June, 2013] => Array (

[0] Courtney Barnett - History Eraser

[1] Delphic - Baiya

)

)

有人可以帮我解决一下我怎么做的?

我想要实现的主要目标是能够将文件放在我的服务器上的文件夹中并打印出我的脚本,形式为< ul>,按照上传的日期分组的歌曲.

Last Updated: 26th of February, 2013

All That Glitters - This Sound (Felix Cartal Remix)Bertie Blackman - Hide and SeekCity Calm Down - Sense of SelfCosmo Jarvis - My Own Thing

Last Updated: 18th of December, 2012

Birds of Tokyo - This FireBloc Party - TruthC2C - Down the RoadChance Waters - Young and Dumb feat Bertie BlackmanClubfeet - Heartbreak

Last Updated: 6th of June, 2013

Courtney Barnett - History EraserDelphic - Baiya

感谢所有试图帮助我的人.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值