尊敬的Xperts,请帮我构建一个多维数组。我有一些变量:
$subject_name = Algorithom
$subject_code = 30103
$department_name = Computer Science
$department_short_name = CSE
$teacher_name = Md. Kibria
$date = 09-APR-2015
$time = 12:00am
$student = // it's an array
$status = // it's an array
和两个这样的数组:
print_r($student) =
Array ( [0] => Md. Tushar Ahmed [1] => Mrs. Monira Akter [2] => JOYNAB
AKTER [3] => BEAUTY AKTER [4] => PURABI BARUA [5] => SETU BISWAS )
print_r($status) =
Array ( [0] => present [1] => absent [2] => absent [3] => leave [4] =>
present [5] => present )
我想要一个像这样的多维数组:
array (
array([0]=>algorithom [1]=> 30103 [2]=>30103 [3]=>computer science
[4]=>cse [5]=>md. kibria [6]=>09-APR-2015 [7]=>12:00AM [8]=>Md. Tushar
Ahmed [9]=> present),
array([0]=>algorithom [1]=> 30103 [2]=>30103 [3]=>computer science
[4]=>cse [5]=>md. kibria [6]=>09-APR-2015 [7]=>12:00AM [8]=> Mrs. Monira
Akter [9]=> absent),
array([0]=>algorithom [1]=> 30103 [2]=>30103 [3]=>computer science
[4]=>cse [5]=>md. kibria [6]=>09-APR-2015 [7]=>12:00AM [8]=> JOYNAB
AKTER [9]=> leave),
and so on . . . .
)
这个多维数组必须从循环中出来。
请帮我完成这个。
提前致谢。
答案 0 :(得分:0)
只需迭代$学生添加这些变量和相应的$状态值:
$array = array();
foreach($students as $k=>$v){
$array[] = array(
$subject_name,
$subject_code,
$subject_code,
$department_name,
$department_short_name,
$teacher_name,
$date,
$time,
$v,
$status[$k]
);
}
你重复了$ subject_code,所以我也做了,但我不确定它是故意的。