Re: [PHP] Create a hierarchical hash from flat source

2011-06-24 Thread Paul M Foster
On Thu, Jun 23, 2011 at 01:57:24PM -0400, Robert Cummings wrote: On 11-06-23 12:54 PM, Tamara Temple wrote: On Jun 22, 2011, at 5:24 PM, Scott Baker wrote: On 06/22/2011 03:17 PM, Simon J Welsh wrote: You still need to pass the value by reference to assign_children(), so: $new

Re: [PHP] Create a hierarchical hash from flat source

2011-06-23 Thread Tamara Temple
On Jun 22, 2011, at 5:24 PM, Scott Baker wrote: On 06/22/2011 03:17 PM, Simon J Welsh wrote: You still need to pass the value by reference to assign_children(), so: $new = $leaf[$pid]; assign_children($pid,$list,$new); One last thing I fixed was that PHP was complaining that run-time pass

Re: [PHP] Create a hierarchical hash from flat source

2011-06-23 Thread Robert Cummings
On 11-06-23 12:54 PM, Tamara Temple wrote: On Jun 22, 2011, at 5:24 PM, Scott Baker wrote: On 06/22/2011 03:17 PM, Simon J Welsh wrote: You still need to pass the value by reference to assign_children(), so: $new =$leaf[$pid]; assign_children($pid,$list,$new); One last thing I fixed was

[PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
I have a bunch of records in a DB that look like id | parent_id -- 1 | 4 2 | 4 3 | 2 4 | 0 5 | 2 6 | 1 7 | 3 8 | 7 9 | 7 I want to build a big has that looks like: 4 - 1 - 6 - 2 - 3 - 7 - 9 - 5 - 8 I'm like 90% of the way there, but I can't get my recursive

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 9:53 AM, Scott Baker wrote: I have a bunch of records in a DB that look like id | parent_id -- 1 | 4 2 | 4 3 | 2 4 | 0 5 | 2 6 | 1 7 | 3 8 | 7 9 | 7 I want to build a big has that looks like: 4 - 1 - 6 - 2 - 3 - 7 - 9 - 5 -

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 9:57 AM, Simon J Welsh wrote: On 23/06/2011, at 9:53 AM, Scott Baker wrote: I have a bunch of records in a DB that look like id | parent_id -- 1 | 4 2 | 4 3 | 2 4 | 0 5 | 2 6 | 1 7 | 3 8 | 7 9 | 7 I want to build a big has that looks

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:06 PM, Simon J Welsh wrote: On further inspection, that's not the problem at all. The problem's around assign_children($pid,$list,$new); The previous line you defined $new with $new = $leaf[$pid], *copying* that node into $new. Thus the assign_children() call updates $new,

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Simon J Welsh
On 23/06/2011, at 10:14 AM, Scott Baker wrote: On 06/22/2011 03:06 PM, Simon J Welsh wrote: On further inspection, that's not the problem at all. The problem's around assign_children($pid,$list,$new); The previous line you defined $new with $new = $leaf[$pid], *copying* that node into

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:17 PM, Simon J Welsh wrote: You still need to pass the value by reference to assign_children(), so: $new = $leaf[$pid]; assign_children($pid,$list,$new); Aha... that was it! Thanks! -- Scott Baker - Canby Telcom System Administrator - RHCE - 503.266.8253 -- PHP General

Re: [PHP] Create a hierarchical hash from flat source

2011-06-22 Thread Scott Baker
On 06/22/2011 03:17 PM, Simon J Welsh wrote: You still need to pass the value by reference to assign_children(), so: $new = $leaf[$pid]; assign_children($pid,$list,$new); One last thing I fixed was that PHP was complaining that run-time pass by reference was deprecated. I changed