#27061 [Opn->Bgs]: using each, getdate and while will output wrong data

From: Date: Tue, 27 Jan 2004 18:02:16 +0000
Subject: #27061 [Opn->Bgs]: using each, getdate and while will output wrong data
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-53970@lists.php.net to get a copy of this message
ID: 27061 Updated by: sniper@php.net Reported By: PAUL_MYERS at YAHOO dot COM -Status: Open +Status: Bogus Bug Type: Output Control Operating System: windows and GNULinux PHP Version: 4.3.4 New Comment: Use '===' and '!==' there. This is not bug.. Previous Comments: ------------------------------------------------------------------------ [2004-01-27 12:55:02] PAUL_MYERS at YAHOO dot COM 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 this bug report at http://bugs.php.net/?id=27061&edit=1

« previous php.bugs (#53970) next »