#27061 [NEW]: using each, getdate and while will output wrong data

From: Date: Tue, 27 Jan 2004 17:55:02 +0000
Subject: #27061 [NEW]: using each, getdate and while will output wrong data
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53967@lists.php.net to get a copy of this message
From: PAUL_MYERS at YAHOO dot COM Operating system: windows and GNULinux PHP version: 4.3.4 PHP Bug Type: Output Control Bug description: using each, getdate and while will output wrong data Description: ------------ running the code below will ouput the weekday value and the Unix datecode! - obviously I have shortened my code so this is non relevant as there is another way but I'm not sure this should happen (it would be interesting to know why?) this can be resolved by changing if ($element[key] == "weekday" ) to if ($element[key] == "weekday" && $element[key] != "0") Reproduce code: --------------- <html> <body> <? $timestamp = date ("U"); $day1a = getdate ($timestamp); while ( $element = each ($day1a)) { if ($element[key] == "weekday" ) { $day = $element[value]; echo " Day "; echo $day; echo "<br><br>"; } } ?> </body> </html> Expected result: ---------------- Day Tuesday Actual result: -------------- Day Tuesday Day 1075224592 -- Edit bug report at http://bugs.php.net/?id=27061&edit=1 -- Try a CVS snapshot (php4): http://bugs.php.net/fix.php?id=27061&r=trysnapshot4 Try a CVS snapshot (php5): http://bugs.php.net/fix.php?id=27061&r=trysnapshot5 Fixed in CVS: http://bugs.php.net/fix.php?id=27061&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=27061&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=27061&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=27061&r=needscript Try newer version: http://bugs.php.net/fix.php?id=27061&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=27061&r=support Expected behavior: http://bugs.php.net/fix.php?id=27061&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=27061&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=27061&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=27061&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27061&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=27061&r=dst IIS Stability: http://bugs.php.net/fix.php?id=27061&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=27061&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=27061&r=float

« previous php.bugs (#53967) next »