Welcome Guest, Not a member yet? Register   Sign In
Little help with recursive function plz
#2

[eluser]marjune[/eluser]
hi! you have to make two arrays in it.

Code:
$childnodes  = array(); //in side in this array would be another array for the name and id.

$id_and_name = array(); // array of your name and id.
$counter     = 0;// counter of the childnodes  array.
$idcounter   = 0;//counter for id_and_name inside the childnodes array

foreach ( $results as $item ) {
                
                // If it is a category, search for more categories
                if ( $item->type == 0 ) {
                    
                    $this->category_model->get_childnodes($item->id);
                // echo $item->id . ' ';
                // echo $item->name . ' ';
                   $id_and_name[$idcounter]   = $item->id;
                   $id_and_name[$idcounter+1] = $item->name ;
                }
                $idcounter++;
       }
      
              // Return an array of ids
        return $childnodes[$counter] = $id_and_name;


Messages In This Thread
Little help with recursive function plz - by El Forum - 06-02-2011, 04:35 PM
Little help with recursive function plz - by El Forum - 06-02-2011, 07:35 PM
Little help with recursive function plz - by El Forum - 06-02-2011, 11:50 PM
Little help with recursive function plz - by El Forum - 06-03-2011, 12:44 AM
Little help with recursive function plz - by El Forum - 06-03-2011, 06:30 AM
Little help with recursive function plz - by El Forum - 06-10-2011, 03:40 AM
Little help with recursive function plz - by El Forum - 06-10-2011, 10:01 AM
Little help with recursive function plz - by El Forum - 06-11-2011, 01:53 AM
Little help with recursive function plz - by El Forum - 06-11-2011, 11:08 AM



Theme © iAndrew 2016 - Forum software by © MyBB