On Tue, Feb 24, 2009 at 3:52 PM, charlie derr wrote:
> Ajai Khattri wrote:
>>
>> On Tue, 24 Feb 2009, csnyder wrote:
>>
>>> What are you fishing for? Write some code and try it.
>>
>>
>> Nice.
>
>
> I initially had a similar reaction when I saw this comment, but when I
> really thought about it, t
John Campbell wrote:
> In php 5.3 we should be able to:
>
> function flatten($arr) {
> $result = array();
> array_walk_recursive($arr,function($k,$v) use (&$result) {$result[] = $v});
> return $result;
> }
>
> Shows the power of closures & lambdas.
That's pretty slick!
> Of course that co
In php 5.3 we should be able to:
function flatten($arr) {
$result = array();
array_walk_recursive($arr,function($k,$v) use (&$result) {$result[] = $v});
return $result;
}
Shows the power of closures & lambdas.
Of course that code is of no use to you.
Try:
function flatten($arr) {
$resu
Ajai Khattri wrote:
On Tue, 24 Feb 2009, csnyder wrote:
What are you fishing for? Write some code and try it.
Nice.
I initially had a similar reaction when I saw this comment, but when I really thought about it, that's the power of PHP (that it's
so easy to just try stuff). Asking a si
On Tue, 24 Feb 2009, csnyder wrote:
> What are you fishing for? Write some code and try it.
Nice.
--
Aj.
___
New York PHP User Group Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
http://www.nyphp.org/show_participation.
On Tue, 24 Feb 2009, justin wrote:
> You could use array_merge() on the way out. Do you want to preserve
> keys, or can you handle getting back a numerically indexed array?
Numerical index is fine.
--
Aj.
___
New York PHP User Group Community Talk M
On Mon, Feb 23, 2009 at 11:12 PM, Ajai Khattri wrote:
> On Mon, 23 Feb 2009, Tim Lieberman wrote:
>
>> Yup, your standard depth-first tree traversal.
>
> But in order to build a flat array, I'd have to pass that by reference
> into my recursive function so it can append the each node right?
>
You
On Mon, Feb 23, 2009 at 11:12 PM, Ajai Khattri wrote:
> On Mon, 23 Feb 2009, Tim Lieberman wrote:
>
>> Yup, your standard depth-first tree traversal.
>
> But in order to build a flat array, I'd have to pass that by reference
> into my recursive function so it can append the each node right?
>
Wha