Sigh
Ive just about managed to get a grip on the whole recursive idea.
I can successfully turn this:
Array
(
[0] => Array
(
[id] => e9f05064bcfb342ac34f335c2bc98370
[category] => Blah
[category_description] => blah desc
[belongto] =>
[children] => Array
(
[0] => Array
(
[id] => 129f30dd47d3a942b840ad2bf4ce5c4f
[category] => Testingz
[category_description] => Haxing, Haxing! I USE DA WPEZ JO!
[belongto] => e9f05064bcfb342ac34f335c2bc98370
[children] => Array
(
[0] => Array
(
[id] => 2e9e963380a3fd4a1a6fb5050c9de331
[category] => Sub-sub category
[category_description] => Man, If this works....
[belongto] => 129f30dd47d3a942b840ad2bf4ce5c4f
[children] =>
)
[1] => Array
(
[id] => 3b1e026bd5698e803731d0bb1712d80d
[category] => Sub sub cate2
[category_description] => TEWHI
[belongto] => 129f30dd47d3a942b840ad2bf4ce5c4f
[children] => Array
(
[0] => Array
(
[id] => 14686710257a89964506c9577e8d55b6
[category] => Sub sub sub cate :)
[category_description] => hello
[belongto] => 3b1e026bd5698e803731d0bb1712d80d
[children] =>
)
)
)
[2] => Array
(
[id] => 1d502987aaa5a231aa7790311ca00ffa
[category] => omg
[category_description] => wtf
[belongto] => 129f30dd47d3a942b840ad2bf4ce5c4f
[children] =>
)
)
)
[1] => Array
(
[id] => d8f8e8a4b5e376f5f791e05a0aa90338
[category] => lll
[category_description] => kkk
[belongto] => e9f05064bcfb342ac34f335c2bc98370
[children] =>
)
)
)
[1] => Array
(
[id] => news
[category] => News
[category_description] => This is the news :)
[belongto] =>
[children] =>
)
)
into this:
Blah
Blah->Testingz
Blah->Testingz->Sub-sub category
Blah->Testingz->Sub sub cate2
Blah->Testingz->Sub sub cate2->Sub sub sub cate 🙂
Blah->Testingz->Sub sub cate2->omg
Blah->Testingz->lll
Blah->News
But if you look closely, its incorrect.
This is the code that is doing it:
function recursion_now($array, $level){
foreach($array as $title){
echo $level . $title['category'] . "<BR>";
if(is_array($title['children'])){
$level .= $title['category'] . "->";
recursion_now($title['children'],$level,$title['belongto']);
}
}
}
Is there anything wrong with it?
because the $level thing is sorta incorrect 🙁
if any one knows, thanks 🙂
Btw, Before you post this "But, I gave you some code, didnt it work?"
The answer is, Well it just did what my script did, not take the level down.