From:             [EMAIL PROTECTED]
Operating system: Windows 98
PHP version:      4.0.5
PHP Bug Type:     Unknown/Other Function
Bug description:  Bug in array handling

<?php
        
    //Two elements in an Array
    $array[] = "Maria";
    $array[] = "Lisa";
        
    //just a test output
    array_walk ($array, "my_print");


    //and then free the first element of the array
    unset ($array[0]);

    function my_print ($value)
    {
        print $value . " ";
    }
        
    print "<br />";
    //The following dump will produce:
    //array(1) { [1]=> string(4) "Lisa" } 
    //This means that the first element has the index 1 
    //But it should have index 0
    var_dump ($array);
?>

If you have more than two elements, and you free one of them, you can just prevent 
this bug, by resorting the array with any sort function. But with only two elements, 
this won't work, and if you clear the first of these, you will get the same result as 
I have got, there was one element,  but with the wrong index.


-- 
Edit Bug report at: http://bugs.php.net/?id=11937&edit=1



-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to