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

[eluser]Jaketoolson[/eluser]
Quote: $id_and_name[$idcounter] = $item->id;
$id_and_name[$idcounter+1] = $item->name ;

this would create the following array:

Code:
array(
    '0' => array(
            '0' => 'id'
            ),
    '1' => array(
            '0' => 'name'
            )
);

Just do this
Code:
$i = 0;
foreach ( $results as $item )
{
  
  $childnodes[$i]['id']   = $item->id;
  $childnodes[$i]['name'] = $item->name;

  $i++;              
}

//creates
array(
    '0' => array(
            id => 'id_2',
            name => 'name'
            ),
    '1' => array(
            id => 'id_3',
            name, 'other 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