Salut je tableau comme cetableau PHP évitent Undefined offset
$subject_names[7]="English";
$subject_names[11]="Software Engeneering";
//Student can choose multiple subjects and each subject have int_mark and ext_mark
$results['Matt'][7]['int_mark'] =15;
$results['Matt'][7]['ext_mark'] =55;
$results['Josh'][7]['int_mark'] =12;
$results['Josh'][7]['ext_mark'] =45;
$results['Josh'][11]['int_mark'] =14;
$results['Josh'][11]['ext_mark'] = 52;
// the array is to maintain crosstab format
Et pour imprimer ce que je l'ai fait
echo "Student Name\t";
foreach($subject_names as $subject_name)
{
echo "$subject_name\t";
}
echo "<br>";
foreach ($results as $student_name => $subjects)
{
echo "$student_name\t";
foreach($subject_names as $subject_id => $sub_name){
foreach ($subjects[$subject_id] as $mark){
echo "$mark\t";
}
}
echo "<br>";
}
Comme étudiant "Matt" n'a pas a id_sujet 11 Il me donne un avis erreur
Notice: Undefined offset: 11
Comment puis-je ignorer et l'impression N/A si l'étudiant pas ce sujet
Merci pour toute votre aide et suggestions
avant impression vérifier 'if (isset ($ array [$ offset]))' –
Mon mauvais, si drôle Comment ai-je ignorer cela MERCI – sanu