Jump to content

Trouble setting variable within do_while script


rrobertson1979

Recommended Posts

Hi!

 

I am trying to get the following code to work. 

 

$recur = "";
$i = 0;

if ($frequency == "weekly"){
$s = date('W', $startDate);
do {
	echo "$s - ";
    $recur .= $s . "/";
	$s = $s + 1;
	$i++;
} while ($i <= 52);}
echo $recur;

 

I get the following output.

 

10 - 11 - 12 - 13 - 14 - 15 - 16 - 17 - 18 - 19 - 20 - 21 - 22 - 23 - 24 - 25 - 26 - 27 - 28 - 29 - 30 - 31 - 32 - 33 - 34 - 35 - 36 - 37 - 38 - 39 - 40 - 41 - 42 - 43 - 44 - 45 - 46 - 47 - 48 - 49 - 50 - 51 - 52 - 53 - 54 - 55 - 56 - 57 - 58 - 59 - 60 - 61 - 62 -

 

10

 

I don't understand why $recur does not print "10/11/12..." instead of "10".

 

Any help is GREATLY appreciated!!!!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.