php - Bugging function with in_array loop -


my site bugging lot (slow loading , missing mysql data) - have found odd explanation. single line in 1 of functions problem.

the function looks this:

function lukkedage($aar) { $aaret = date("y", $aar);  $lukkedagearray = array( date("d-m-y",easter_date($aaret)),          //påskedag date("d-m-y",easter_date($aaret)-259200),   //skærtorsdag date("d-m-y",easter_date($aaret)-172800),   //langfredag date("d-m-y",easter_date($aaret)+86400),    //2. påskedag date("d-m-y",easter_date($aaret)+2246400),  //store bededag date("d-m-y",easter_date($aaret)+3369600),  //kristi himmelfart date("d-m-y",easter_date($aaret)+4233600),  //pinsedag date("d-m-y",easter_date($aaret)+4320000),  //2. pinsedag "24-12-".$aaret, "25-12-".$aaret, "26-12-".$aaret, "27-12-".$aaret, "28-12-".$aaret, "29-12-".$aaret, "30-12-".$aaret, "31-12-".$aaret, "01-01-".$aaret );  return $lukkedagearray; }   function naestearbejdsdag($dato) { $naeste = date('d-m-y h:i', strtotime(date("d-m-y h:i",$dato) .' +1 day')); $strnaeste = strtotime($naeste);  $ny = $strnaeste; while(date("l",$ny) == "sunday" or date("l",$ny) == "saturday"  or in_array(date("d-m-y",$strnaeste), lukkedage($strnaeste), true) ){ $ny += 60*60*24; }  if(date("h",$ny) >= "17" or date("h",$ny) < "09"){ $ny = strtotime(date("d-m-y",$ny)."09:00"); }  return date("d-m-y h:i",$ny); } 

the first function array contains of holidays, , next function checks when next workday - if tomorrow saturday or sunday or holiday, skip next day.

the part making me crazy is:

or in_array(date("d-m-y",$strnaeste), lukkedage($strnaeste), true)) 

shouldn't work? believe reason problems extremely long execution time - why?

a few problems see straight away:

1: easter_date() function missing.

2: use $ny , $strnaeste variables in while loop, update $ny. use 1 variable.

$ny = $strnaeste; while(date("l",$ny) == "sunday" or        date("l",$ny) == "saturday" or        in_array(date("d-m-y",$ny), lukkedage($ny), true)) $ny += 60*60*24; 

Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -