You assume the order matters to me, and that overwriting isn't it's intended behaviour.
 
The fact remains that I'm creating this object, and it says "cannot find element in 
variable". 
 
Does ANYONE know what this means?

        -----Original Message----- 
        From: Curt Zirzow [mailto:[EMAIL PROTECTED] 
        Sent: Wed 7/21/2004 12:58 AM 
        To: [EMAIL PROTECTED] 
        Cc: 
        Subject: Re: [PHP] PHP5 - Weird Error - "cannot find element in variable"
        
        

        * Thus wrote Scott Hyndman:
        >
        > Now here's the problem. When I'm debugging this thing, the line that
        > I've marked doesn't actually add anything to the array. If I try to view
        > the contents of the array, it gives me a "cannot find element in
        > variable" error. Later, when I iterate through it, two elements are
        > outputted (don't ask me why, my iterator is perfect, I checked). Can
        > someone shed some light on this? It's pretty annoying...in the mean
        > time, I'll just use arrays.
        
        There are many things that can be going wrong. First thing is that
        your collection object is relying on an external value for its
        internal index.
        
        Second, being that it is external, the value may be repeating
        itself, or as what has been pointed out earlier, is being converted
        to true/false.
        
        Third, from the looks of the code, it looks like your trying to
        force the index to be the order of the position of the object:
        
            <?php
            $ar[5] = 'last';
            $ar[1] = 'first';
            $ar[4] = 'second';
        
            print_r($ar);
        
            /*
            Array
            (
               [5] => last
               [1] => first
               [4] => second
            )
            */
        
        As noted in the output, php simply pushes new key/values to the
        end.
        
        Fourth, how are you accessing the array to get the 'cannot find
        element in variable' error. I've never heard of such an error.
        
        And finally, print_r($this->arr_objects), each time you Add(), and
        see how exactly the array looks each time.  If you have more than
        two elements after the last Add(), then your iterator is most
        likely not working properly.
        
        
        Curt
        --
        First, let me assure you that this is not one of those shady pyramid schemes
        you've been hearing about.  No, sir.  Our model is the trapezoid!
        
        --
        PHP General Mailing List (http://www.php.net/)
        To unsubscribe, visit: http://www.php.net/unsub.php
        
        

Reply via email to