0
I cannot show sequence element of a timed array.
I created a variable $hora that stores the local time, and an array with several times $os, then I search for an equal time, if it shows, but if you don’t want to show the next time.
Look what I’ve done:
$hora = date('Hi');
$os = array('1632','1635','1638','1654','1642');
if( in_array($hora, $os)){
echo "Proximo onibus as : " . $hora;
}else{
echo // Comparar e dar o valor subsequente ao valor da hora
// encontrada
}
};
Any suggestions?
What if there is no subsequent value? What should happen?
– Berriel
In fact this array will be a "table" with bus schedules, in case you don’t think I should put another Else at the end with some msg. Ex: now it is 17:47 , suppose the guy consulted and and the last value was 17:45, then he shows the next value by ex 18:00 ..
– Leo
Leo, see this post: Get Next. Should help you.
– Fernando A.W.