Jim,
Read the first emails, your idea was my initial design, eg.
$sorted= array();
recrusion($array, &$sorted);
var_dump( $sorted );
It's not a "nice" solution due to a need to create variable before the call.
Using my final function it will return sorted array into new variable eg
$sorted = recu
David Sky wrote:
Hey,
Can't use your example, as you check weather
$sorted is empty, if it is -> run the foreach and return,
but on next recursion when it's not empty - do nothing :)
Though I found how to cut a few seconds (on very big array),
removing the first if, and adding a $return=true to
That's true. My fault. I forgot the recrusion call ;-)
I think that is the better solution so far, and it is far far away (better)
that the one you posted at first
On 01/07/2008, David Sky <[EMAIL PROTECTED]> wrote:
>
> Hey,
>
> Can't use your example, as you check weather
> $sorted is empty, if
Hey,
Can't use your example, as you check weather
$sorted is empty, if it is -> run the foreach and return,
but on next recursion when it's not empty - do nothing :)
Though I found how to cut a few seconds (on very big array),
removing the first if, and adding a $return=true to functions'
paramet
Hi David,
That's good work ;-)
You are right that my example would only return one entry for each parent.
Didn't realized of that.
I know the local copies you create in the recursive calls is not the best
solution in efficiency, but lots of times it is better to have local copies
of the array (i
Hey Robero,
Thanks for the answer, the none recursion function is a good idea,
although as provided in your example if would only return one
entry from each parent it can get to and it only can get to few,
depends on how the array is sorted.
Basically you can make it work if you would sort the ar
That's not the problem. Look that the function is called with &$return, so
there is a reference to the variable in which the function returns the value
(if not there would not be an answer...).
Otherwise, i think the problem is in the recursive call inside the function.
Once you make the unset, yo
On Sun, 2008-06-29 at 18:25 -0800, David Sky wrote:
> Hello everyone!
>
> A couple of days ago I submitted a bug to PHP
> http://bugs.php.net/bug.php?id=45385
> But I was mistaken, apparently it's not a bug.
> And I was "sent" here to get help.
I think you might be forgetting to return $return.
]
Sent: Monday, June 30, 2008 12:09 PM
To: php-general@lists.php.net
Subject: Re: [PHP] unset in foreach breaks recrusion
David Sky wrote:
> Hello everyone!
>
> A couple of days ago I submitted a bug to PHP
> http://bugs.php.net/bug.php?id=45385
> But I was mistaken, apparently
David Sky wrote:
> Hello everyone!
>
> A couple of days ago I submitted a bug to PHP
> http://bugs.php.net/bug.php?id=45385
> But I was mistaken, apparently it's not a bug.
> And I was "sent" here to get help.
> [snip]
> So before I write a reply to the bug i submitted, I wanted to know
> if ther
Hello everyone!
A couple of days ago I submitted a bug to PHP
http://bugs.php.net/bug.php?id=45385
But I was mistaken, apparently it's not a bug.
And I was "sent" here to get help.
Although I did tried what was suggested in the response,
Actually I tried it before I wrote about the bug, as I foun
11 matches
Mail list logo