0

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

1 Answer 1

3
$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;
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.