Jump to content

Raliare

New Members
  • Posts

    1
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Raliare's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I'm building a simple CMS system to learn more about PHP as work does not tax me. After much trial and error I've got a script working to collect children of children indefinitely and add them all into an array. My problem is I need to pass the array it's current location or else all new elements will be placed in the first array and not nested arrays for each child. The function is looking for all top level pages (first level pages have a parent Id of -1). then it runs its self going down branch level to find children of that element, then finding those children and so on. function test($parentID, $table_index='') { $child_arr = $this->query_database('', '', 'SELECT * FROM page WHERE parentID ='.$parentID); $count_children = count($child_arr); for($c=0; $c<$count_children; $c++) { $table_index .= '['.$c.']'; $this->page_list+$table_index = $child_arr[$c]['title']; $this->test($child_arr[$c]['ID'], $c); } print_r($this->page_list); //return $this->page_list; } The function is called and passed the top level parent id of "-1". It all works fine apart from $this->page_list+$table_index = $child_arr[$c]['title']; Just how do I construct and pass along my new location in the multidimensional array and pass this to the next iteration of the function so that the script knows where to insert the data? Or is there a better way to do this?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.