Jump to content

find using repeater


SIERRA
 Share

Recommended Posts

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

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/>";
}

 

  • Like 4
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...