如何根据php中的特定键创建排序的多维数组
我有一个数组,我想根据其中的特定索引创建一个多维数组。
Array
(
[0] => Array
(
[notecata] => Tele Call
[user_id] => 1
[note_key] => 4977f48e
[note_title] => Urgent Call to Soorya
[note_description] => want to discuss about the work
[added_on] => 15-11-11
)
[1] => Array
(
[notecata] => Set PlaceMent Drive
[user_id] => 1
[note_key] => b8b25bd8
[note_title] => Want to collect biodata from Students
[note_description] => Soorya must do this very well
[added_on] => 15-11-11
)
[2] => Array
(
[notecata] => Conference
[user_id] => 1
[note_key] => 3cdb4886
[note_title] => Sunday Meeting
[note_description] => About new courses
[added_on] => 08-11-11
)
)
我想得到以下输出
Array
(
[15-11-11] => Array
(
[0] => Array(
[notecata] => Tele Call
[user_id] => 1
[note_key] => 4977f48e
[note_title] => Urgent Call to Soorya
[note_description] => want to discuss about the work
)
[1] => Array(
[notecata] => Set PlaceMent Drive
[user_id] => 1
[note_key] => b8b25bd8
[note_title] => Want to collect biodata from Students
[note_description] => Soorya must do this very well
)
)
[8-11-11] => Array
(
[0] => Array(
[notecata] => Conference
[user_id] => 1
[note_key] => 3cdb4886
[note_title] => Sunday Meeting
[note_description] => About new courses
)
)
)
I have an array that I would like to make a multidimensional array based on a particular index in it.
Array
(
[0] => Array
(
[notecata] => Tele Call
[user_id] => 1
[note_key] => 4977f48e
[note_title] => Urgent Call to Soorya
[note_description] => want to discuss about the work
[added_on] => 15-11-11
)
[1] => Array
(
[notecata] => Set PlaceMent Drive
[user_id] => 1
[note_key] => b8b25bd8
[note_title] => Want to collect biodata from Students
[note_description] => Soorya must do this very well
[added_on] => 15-11-11
)
[2] => Array
(
[notecata] => Conference
[user_id] => 1
[note_key] => 3cdb4886
[note_title] => Sunday Meeting
[note_description] => About new courses
[added_on] => 08-11-11
)
)
I want to get the following output
Array
(
[15-11-11] => Array
(
[0] => Array(
[notecata] => Tele Call
[user_id] => 1
[note_key] => 4977f48e
[note_title] => Urgent Call to Soorya
[note_description] => want to discuss about the work
)
[1] => Array(
[notecata] => Set PlaceMent Drive
[user_id] => 1
[note_key] => b8b25bd8
[note_title] => Want to collect biodata from Students
[note_description] => Soorya must do this very well
)
)
[8-11-11] => Array
(
[0] => Array(
[notecata] => Conference
[user_id] => 1
[note_key] => 3cdb4886
[note_title] => Sunday Meeting
[note_description] => About new courses
)
)
)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用这个功能
use this function
可能的解决方案:
获取所有日期,排序;
在循环中,查找与日期匹配的记录,将其所有内容添加到“索引”中的结果数组中;
Possible soln:
Get all the dates, sort it;
In a loop, find a record matching the date, add all contetns it to resulting array in '' index;
尝试这个:
得到以下结果:
try this one:
Got the following result:
试试这个:
查看工作演示
try this:
SEE WORKING DEMO