php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #37762 Array Associative in a for using the wrong key crash the system
Submitted: 2006-06-09 13:21 UTC Modified: 2006-06-09 16:02 UTC
From: bits dot e dot bytes at gmail dot com Assigned:
Status: Not a bug Package: Arrays related
PHP Version: 5.1.4 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bits dot e dot bytes at gmail dot com
New email:
PHP Version: OS:

 

 [2006-06-09 13:21 UTC] bits dot e dot bytes at gmail dot com
Description:
------------
When i make a for in a array associative, but using some wrong key like numeric, this crash the system.
Please see the code 

Reproduce code:
---------------
protected function getArray() {
    $days = array();
    for ($i = 31; $i > 0; $i--) {
        $day  = mktime (0, 0, 0, date("m")  , date("d")-$i, date("Y"));
        if (date('w', $day) != 0 && date('w', $day) != 6 ){
            $days[] = date('d/m/Y', $day);
        }
    }
    $days = array_flip($days);
    for ($i = 0; $i < count($days); $i++) {
//Here is the problem, becouse insted of use a correct key, i use a number. In this point the system crash.
        $days[$i] = 0;
    }
    return $days;
}



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2006-06-09 16:02 UTC] mike@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

You create an endless loop.
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Fri Dec 13 21:01:24 2019 UTC