SIERRA Posted April 24, 2018 Share Posted April 24, 2018 I am creating repeater as below for table booking in a restaurant. To find a timing slot for a specific day I am using below loop. Please suggest is this correct or is there any other optimized way of doing this. Thanks normal_days time_from time_to special_days date_value (this is a date field) time_from time_to PHP code $datetofind=strtotime($date); foreach($page->special_days as $special_day) { if ($special_day->date_value==$datetofind){ $slot_txt=""; if ($special_day->time_from!="" && $special_day->time_to!="") $slot_txt.=$special_day->time_from." to ".$special_day->time_to."<br/>"; } } …. Link to comment Share on other sites More sharing options...
elabx Posted April 24, 2018 Share Posted April 24, 2018 Try: $datetofind=strtotime($date); foreach($page->special_days->find("date_value={$datetofind}, time_from!='', time_to!=''") as $special_day) { $slot_txt.=$special_day->time_from." to ".$special_day->time_to."<br/>"; } 4 Link to comment Share on other sites More sharing options...
SIERRA Posted April 25, 2018 Author Share Posted April 25, 2018 This is working.Thanks! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now