lundi 19 octobre 2015

Php Calender Week Range

I want to concate a php range so to say, code looks like this so far:

$var1 = $date->format('W');

if($var2 > 52) {

    $var2 = $var2 % 52;

}

    $numbers = range($var1,$var2);

    shuffle($numbers);

    foreach($users as $user) {

        $uniqueRand = array_pop($numbers);
        ...
    }

So I want to give the users at my database a random number / calenderweek, which is between the current calender week and a the current calender week +15.

I am checking if the calender week of var2 is higher than 52, if it is higher then the calender week starts from 1, in my case the calender weeks are from 43 - 6.

The problem is now that the range goes from 43 to 6, but I want that the range does from 43 to 52 and than from 1 to 6 , does anyone have a good solution for this issue.




Aucun commentaire:

Enregistrer un commentaire