Advertisement
AlexWebDevelop

Untitled

Sep 25th, 2019
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.57 KB | None | 0 0
  1. <?php
  2.  
  3. /* Array with the full times list */
  4. $startTimes = array();
  5.  
  6. /* Array with the already used times */
  7. $arr = array();
  8.  
  9. /* This is the select HTML code */
  10. $select = '<select name="mySelectName">';
  11.  
  12. /* Now, we build the options list */
  13.  
  14. foreach ($startTimes as $time)
  15. {
  16.     $select .= '<option value="' . htmlspecialchars($time) . '"';
  17.    
  18.     /* Disable the option if the time is used */
  19.     if (in_array($time, $arr))
  20.     {
  21.         $select .= ' disabled="disabled"';
  22.     }
  23.    
  24.     $select .= '>' . htmlspecialchars($time) . '</option>';
  25. }
  26.  
  27. $select .= '</select>';
  28. echo $select;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement