I have a problem creating a recursive function to convert a list to an object :
location :
12 :
label : 'city 1'
children:
13 :
label:'city2'
children :
14 :
label : 'city3'
15 :
label : 'city4'
children :
16 :
.....
.....
122 :
label : 'city 100'
........
So I hope to create a recursive function to return an object with all my list above with something like that :
public static function getLocation($config , $id )
{
$id= current($config['id'])
$label = $config['id']['label']
$children = $config['id']['label']['children']
....
if(!empty($children) ){
}else{
foreach( ){
getLocation($config , $id );
}
}
return $obj;
}