永发信息网

php如何将一些数组放进一个大数组里面?

答案:2  悬赏:40  手机版
解决时间 2021-01-26 12:21
  • 提问者网友:那叫心脏的地方装的都是你
  • 2021-01-25 11:46
现在有这些数组:
Array('date' => '2011-11-30','week' => '周三001'),
Array('date' => '2011-11-30','week' => '周三002'),
Array('date' => '2011-11-30','week' => '周三003'),
Array('date' => '2011-12-01','week' => '周四001'),
Array('date' => '2011-12-01','week' => '周四002'),
Array('date' => '2011-12-01','week' => '周四003'),
Array('date' => '2011-12-02','week' => '周五001'),
Array('date' => '2011-12-02','week' => '周五002'),
Array('date' => '2011-12-02','week' => '周五003'),
Array('date' => '2011-12-03','week' => '周六001'),
Array('date' => '2011-12-03','week' => '周六002'),
如何将这些数组放到一个大数组里,变成这样的:
$weekDate = array(
Array('date' => '2011-11-30','week' => '周三001'),
Array('date' => '2011-11-30','week' => '周三002'),
Array('date' => '2011-11-30','week' => '周三003'),
Array('date' => '2011-12-01','week' => '周四001'),
Array('date' => '2011-12-01','week' => '周四002'),
Array('date' => '2011-12-01','week' => '周四003'),
Array('date' => '2011-12-02','week' => '周五001'),
Array('date' => '2011-12-02','week' => '周五002'),
Array('date' => '2011-12-02','week' => '周五003'),
Array('date' => '2011-12-03','week' => '周六001'),
Array('date' => '2011-12-03','week' => '周六002'),
)
最佳答案
  • 五星知识达人网友:西风乍起
  • 2021-01-25 13:26
当你循环产生哪些数组的时候
你就这样
$big_array[] = Array('date' => '2011-11-30','week' => '周三001');
......

这样就行了,这样就会自动在$big_array这个数组后面追加那些小数组。
全部回答
  • 1楼网友:走死在岁月里
  • 2021-01-25 13:40
$sqlpingpai1="select pinpai,pinpaiimg from dianpu where pinpai!=0"; $resultpingpai1=mysql_query($sqlpingpai1); $arr; while($pingpai1=mysql_fetch_assoc($resultpingpai1)) { $arr[]=array($pingpai1['pinpai'],$pingpai1['pinpaiimg']); } 这样填充完之后就是二维数组了,获取的话要用$arr[0][0]这种形式获取,也可以用索引形式的,如果楼主感兴趣,请追问,将告知索引形式的
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯