2010-07-16 4 views
0

J'ai trois tableaux:3array mettre la sortie dans le tableau php

$arr_student_name = array('bharani','vasanth','kumar'); 
$arr_student_dept = array('CSE','ECE','EEE'); 
$arr_student_year = array('2','3','4'); 

Je veux quelque chose comme de sortie ce,

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

Comment construire la somthing de sortie comme ci-dessus?

Chaque colonne est un tableau séparé, mais je veux sortir quelque chose comme ci-dessus.

Conseiller

Répondre

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; 
+0

yes man ..Je oublié cette méthode ... – Bharanikumar

Questions connexes