Re: Referencing Multi Dimensional Arrays

From: Date: Wed, 01 Dec 2004 20:04:42 +0000
Subject: Re: Referencing Multi Dimensional Arrays
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-203254@lists.php.net to get a copy of this message
Robinson, Matthew wrote: > I've kind of solved this question already using recursion but I > recon (in the grand tradition) that someone has a better solution! Recursion and http://php.net/is_array is probably the most clear-cut solution. If you are concerned that the arrays could become *SOOOO* deep and huge that rrecursion will blow up the stack, then most times you can take your straight-forward recursive algorithm, and convert it to an almost-as-straight-forward iterative algorithm. In fact, it's been proven that any "tail recursion" can be converted to iteration. Some terminology that may be meaningless to the Reader, loosely translated into English, partly for the amusement of Readers who do understand this terminology: "blow up the stack" - a function that calls itself so often that it ends up eating up the whole computer in a fit of self-indulgent gorging on its own beautiful voice. "tail recursion" - recursion where the function call to recurse is at the tail end of the function -- the last line, not counting closing brackets. "iterative" - a simple "for" or "while" loop PS The real solution may be to not store your data in that manner, as it clearly is giving you trouble... -- Like Music? http://l-i-e.com/artists.htm

« previous php.general (#203254) next »