php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27061 using each, getdate and while will output wrong data
Submitted: 2004-01-27 12:55 UTC Modified: 2004-01-27 13:02 UTC
From: PAUL_MYERS at YAHOO dot COM Assigned:
Status: Not a bug Package: Output Control
PHP Version: 4.3.4 OS: windows and GNULinux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: PAUL_MYERS at YAHOO dot COM
New email:
PHP Version: OS:

 

 [2004-01-27 12:55 UTC] 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



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-01-27 13:02 UTC] sniper@php.net
Use '===' and '!==' there. This is not bug..

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Mon May 12 05:01:28 2025 UTC