Guest User

Arrays

a guest
Feb 23rd, 2019
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // horários que são exibidos para os clientes
  2. $hours = array('08:00','08:30','09:00','09:30','10:00','10:30','11:00','11:30','12:00','12:30','13:00','13:30','14:00');
  3.  
  4. // horários que os clientes marcaram
  5. $schedule = array('08:00','08:00','09:00','09:00','09:00','10:00','10:00','10:00','10:00','11:00','11:00','11:00','11:00','11:00' );
  6.  
  7. // ao chegar nesse valor de consultas agendada por horário é retirado o horário do array hours
  8. $chooseNumber = 5;
  9.  
  10. $count = array_count_values( $schedule );
  11. foreach( $count as $number => $value )
  12. {
  13.  
  14. if( $value > 1 )
  15. {
  16. $schedules[$value] = $number;
  17.  
  18. if( $value == $chooseNumber )
  19. {
  20. $newHours[$value] = $number;
  21. }
  22.  
  23. }
  24.  
  25.  
  26. }
  27. echo "<pre>";
  28. print_r( $schedules );
  29. echo "</pre>";
  30.  
  31. echo "<pre>";
  32. print_r( array_diff( $hours, $newHours ) );
  33. echo "</pre>";
RAW Paste Data