开发者

3array bring output in table php

I have three arrays:

$arr_student_name开发者_运维技巧 = array('bharani','vasanth','kumar');
$arr_student_dept = array('CSE','ECE','EEE');
$arr_student_year = array('2','3','4');

I want output something like this,

Name        Dept Year
Bharani     CSE   2
vasanth     ECE   3
kumar       EEE   4

How to build the output somthing like above?

Each column is a separate array but I want output something like above.

Advise


$arr_student_name = array('bharani', 'vasanth', 'kumar');
$arr_student_dept = array('CSE', 'ECE', 'EEE');
$arr_student_year = array('2', '3', '4');
$str = '<table>';
$str .= '<tr><td>Name</td><td>Dept</td><td>Year</td></tr>';
for ($i = 0; $i <= count($arr_student_name); $i++) {
    $str .= '<tr><td>'.$arr_student_name[$i].'</td><td>'.$arr_student_dept[$i].'</td><td>'.$arr_student_year[$i].'</td></tr>';
}
$str .= '</table>';
echo $str;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜