I have an array that looks like this
Array
(
[0] => Array
(
[id] => 1
[label] => computer
[parent] => 0
[child] => Array
(
[0] => Array
(
[id] => 2
[label] => portable
[parent] => 1
[child] => Array
(
)
)
[1] => Array
(
[id] => 3
[label] => fixe
[parent] => 1
[child] => Array
(
[0] => Array
(
[id] => 4
[label] => case
[parent] => 3
[child] => Array
(
)
)
[1] => Array
(
[id] => 5
[label] => motherboard
[parent] => 3
[child] => Array
(
)
)
)
)
)
)
)
And i want to display in input select
computer->portable
computer->fixe->case
computer->fixe->motherboard
So I want to display all of the categories.
I think I can get there with a recursion.
Do you have any ideas?
The solution:
function listeParent($id){
$parent = ezine_query('SELECT * FROM itvgc_familles_articles WHERE famille_id="'.$id.'";');
$info_parent =mysqli_fetch_object($parent);
if ($info_parent->famille_parent!='') {
listeParent($info_parent->famille_parent);
}
echo $result .= $info_parent->famille_libelle.'>';
}
i loop on the array and i search the label