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
 [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

Add a Patch

Pull Requests

Add a Pull Request

History

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

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 17:01:29 2024 UTC