I am trying to loop through a list of objects, It happily loops through most of the objects, and works for the majority of them, however a couple of times (and always for the same ones) it will not work. I am trying to add the object to the list if its ID does not match he Teacher ID of a previous Lesson in that time period (SubBlock/SB), the one particular ID that it doesn't seem to like is 'ECA', who is free to tech all the lessons, out of the 6 i am trying to get it to pick ECA (the old viable option)it works on attempt 1,3,5 but not 2,4,6, The function it is working through is below
function getRelaventFreeTeachers(&$PossibleTeachers, $Teachers, $Lessons, $SB){
foreach ($Teachers as $TeacherID){
$Usability = 1;
foreach ($Lessons as $Lesson){
$LT = $Lesson->getLessonTeacher();
$T = $TeacherID->getTID();
$LSB = $Lesson->getBlock();
if ($LT != $T){
if ($LSB != $SB){
$Usability = 1;
}
}else{
$Usability = 0;
}
}
if ($Usability == 1){
array_push($PossibleTeachers, $TeacherID);
}
}
}
Aucun commentaire:
Enregistrer un commentaire