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
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:
14 + 32 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC