SV: Weird problems passing variables

From: Date: Sun, 19 Aug 2001 19:57:15 +0000
Subject: SV: Weird problems passing variables
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-63413@lists.php.net to get a copy of this message
Thanks dude, that looks way nicer. I did however get it working by changing the casting (tried to post my correction, but hit the wrong button), the corrected, and after Lynch's enlightening me on mktime´s behaviour even butt uglier code can be found below. (Change in arguments is solely due to a redesign of the form). On a mere philosophical level I'd like to know how the original code could work on IE5, it's also got a dead obvious bug in the zeroPadDate() function (didn't set $mstr or $dstr when month>=10 or day>=10). And no, it wasn't due to using different arguments to the script on the different browsers... Anyway, thanks! //Claes /* Function getDates(from, to) takes strings containing dates in the form "YYYY-MM-DD" and returns an array containing the dates between "from" and "to" inclusive */ function getDates($f_year, $f_month, $f_date, $t_year, $t_month, $t_date) { $year=(int) $f_year; $month=(int) $f_month; $date=(int) $f_date; $to=zeroPadDate((int) $t_year, (int) $t_month,(int) $t_date); $datearray[0]=zeroPadDate($year, $month, $date); $current=$datearray[0]; while($current!=$to) { $date=$date+1; if(checkdate($month, $date, $year)) { $current=zeroPadDate($year, $month, $date); $datearray[]=$current; } else { $month=$month+1; $date=1; if (checkdate($month, $date, $year)) { $current=zeroPadDate($year, $month, $date); $datearray[]=$current; } else { $year=$year+1; $month=1; $current=zeroPadDate($year, $month, $date); $datearray[]=$current; } } } return $datearray; } /* Accessory function to getDates above. */ function zeroPadDate($year, $month, $date) { if ($month<10) { $mstr="0$month"; } else { $mstr=$month; } if ($date<10) { $dstr="0$date"; } else { $dstr=$date; } return "$year-$mstr-$dstr"; }

« previous php.general (#63413) next »