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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
38 + 28 = ?
Subscribe to this entry?

 
 [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: Sun Jul 06 10:01:32 2025 UTC