fork(9) download
  1.  
  2. <?php
  3. $horario = array(
  4. 0 => array('weekday'=> 'Segunda', 'open'=>array(array(8, 14), array(16, 23))),
  5. 1 => array('weekday'=> 'Terça', 'open'=>array(array(8, 14), array(16, 23))),
  6. 2 => array('weekday'=> 'Quarta', 'open'=>array(array(8, 14), array(16, 23)))
  7. );
  8. $dia_semana = date('w');
  9. $hora = intval(date('h'));
  10. $status = 'Fechado';
  11.  
  12. $html = '<h3>Informações</h3>';
  13. for($i = 0; $i < count($horario); $i++){
  14. $dia = $horario[$i];
  15.  
  16. $html.= "<h4>".$dia['weekday']."</h4>";
  17. foreach($dia['open'] as $horas){
  18. if ($dia_semana == $i && $hora > $horas[0] && $hora < $horas[1]) $status = 'Aberto';
  19. $html.= "<p>".$horas[0]." - ".$horas[1]."</p>";
  20. }
  21. }
  22. echo $html;
  23. echo "<p><strong>".$status."</strong></p>";
  24.  
Success #stdin #stdout 0.02s 24400KB
stdin
Standard input is empty
stdout
<h3>Informações</h3><h4>Segunda</h4><p>8 - 14</p><p>16 - 23</p><h4>Terça</h4><p>8 - 14</p><p>16 - 23</p><h4>Quarta</h4><p>8 - 14</p><p>16 - 23</p><p><strong>Aberto</strong></p>