我有52周的数组,每周数组有一个包含9个值的子数组。 现在我需要在每个数组的开头添加一个值0,每隔一周我需要多一个值。
例如(注意0-8将在for循环中)
$vruchtzettings_week["week1"][0-8] = 1, 2, 3, 4, 5, 6, 7, 8, 9
$vruchtzettings_week["week2"][0-8] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
$vruchtzettings_week["week3"][0-8] = 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
$vruchtzettings_week["week4"][0-8] = 0, 0, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
答案 0 :(得分:1)
使用array_unshift()
,就像这样
$week=[1,2,3,4,5,6,7,8,9];
array_unshift($week,0); //[0,1,2,3,4,5,6,7,8,9]