Can anyone tell me what's happening in this code? The first querie works however it does not go into condition within the for. The second works and behaves normally, no problem with this. The case is that I have never seen this before my comparison inside for it never gets true even though they are both of the same length and of the same type.
follow the code:
public function getDias($dia){
$sql=$this->conn->query("SELECT * FROM agendamento WHERE dia = '$dia'");
// $sql=$this->conn->query("SELECT * FROM agendamento");
$horaBD = array(8=>"1");
$responseArr = [];
while($row = $sql->fetch_assoc()){
array_push($horaBD,date("H:i",strtotime($row['horario'])));
}
for ($i=9; $i <= 18; $i++) {
$horaFor = ($i<10) ? "0".$i.":00" : $i.":00";
if ($horaFor == @$horaBD[$i]) continue;//aqui eu substitui por and para funcionar do jeito esperado
else array_push($responseArr,$horaFor);
}
echo "<br>". json_encode($responseArr);
}
as read by LipESprY:
horaFor : 09:00 horaDB: 10:00
horaFor : 10:00 horaDB: 11:00
horaFor : 11:00 horaDB: 15:00
horaFor : 12:00 horaDB: 11:00
horaFor : 13:00 horaDB: 15:00