[nycphp-talk] Flattening a Tree
csnyder
chsnyder at gmail.com
Mon Feb 23 18:45:10 EST 2009
On Mon, Feb 23, 2009 at 6:12 PM, Ajai Khattri <ajai at bitblit.net> wrote:
>
> Best way to flatten a multi-dimensional array of objects into a single dimensional array?
Append each sub-key's name to the current name, separated by an underscore.
$deep['foo']['bar']['quux']
becomes
$flat['foo_bar_quux']
Provided the keys don't have underscores in them already, of course. ;-)
This happens all the time when people want to get data into Excel or
CSV for statistical analysis.
More information about the talk
mailing list