开发者

3array bring output in table php

开发者 https://www.devze.com 2023-01-07 06:40 出处:网络
I have three arrays: $arr_student_name开发者_运维技巧 = array(\'bharani\',\'vasanth\',\'kumar\');

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

精彩评论

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