Re: Re: Get recursive array

From: Date: Tue, 07 Feb 2006 11:08:15 +0000
Subject: Re: Re: Get recursive array
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-230039@lists.php.net to get a copy of this message
Bruno B B Magalhães wrote:
Hi Jochem, well, thanks for the code... it's working perfect, but it seams a little bit slow as it's using while... doesn't?
slow as compared to what? - its a very basic loop. maybe a foreach loop would run quicker but unless you we're calling this method 10,000s of times per request I doubt you see any difference. I don't actually know which would be theoretically faster anyway.
Now, abusing of you, how can I unset a variable the same recursive way? :D Maybe like this?
not to seem rude - but have you bothered to try it out? looks like it should work btw.
    / ***********************************************************************
    * @function_name get_var
    * @function_type Method
    * @function_input None
    * @function_description None
     ***********************************************************************/
    function get_var()
    {               $arguments = func_get_args();
               if(empty($arguments))
        {
            return null;
        }
               $reference =& $this->vars;
               while($argument = array_shift($arguments))
        {
            if(!isset($reference[$argument]))
            {
                return null;
            }
            else
            {
                $reference =& $reference[$argument];
            }
        }
        unset($reference);
    }
And I didn't double posted, I had to subscribe... and I didn't know if my message had been sent or not.
righto - no big deal either way :-) it might get annoying if double posted all day every day though ;-)
Thanks, Bruno B B Magalhaes


« previous php.general (#230039) next »