0
你好,我有一個像下面的導航數組。遞歸函數來創建一個新的多維數組
我不得不刪除一些節點何在「硬粒小麥」條件EQ爲0
而且注意,如果它是一個父節點,它等於0,沒有後裔將被列入。 我不得不使用下面的遞歸函數。但我無法成功。
謝謝。
function visibleCheck(&$array)
{
$result = array();
foreach ($array as $key => $value) {
if($value['durum'] == 1)
{
if(isset($value['children']))
{
$this->visibleCheck($value['children']);
}
$result[] = $value;
}
}
return $result;
}
Array
(
[0] => Array
(
[id] => 391
[name] => Ana Sayfa
[link] => Ana-Sayfa
[durum] => 1
[visible] => 1
[lft] => 2
[rgt] => 3
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 1
[usort] =>
[search] => 0
)
[1] => Array
(
[id] => 393
[name] => Hakkımızda
[link] => Hakkimizda
[durum] => 1
[visible] => 1
[lft] => 6
[rgt] => 7
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 1
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[2] => Array
(
[id] => 394
[name] => Referanslar
[link] => Referanslar
[durum] => 1
[visible] => 1
[lft] => 8
[rgt] => 25
[lang_id] => 1
[menu_id] => 10
[slug] => comp_seperator
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 1
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 403
[name] => Teslim Edilen Projeler
[link] => Teslim-Edilen-Projeler
[durum] => 0
[visible] => 0
[lft] => 9
[rgt] => 20
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 33
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 405
[name] => Aegean - 30m
[link] => Aegean-30m
[durum] => 1
[visible] => 1
[lft] => 10
[rgt] => 11
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 11
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[1] => Array
(
[id] => 406
[name] => Caner IV - 40m.
[link] => Caner-IV-40m
[durum] => 1
[visible] => 1
[lft] => 12
[rgt] => 13
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 13
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[2] => Array
(
[id] => 407
[name] => Carpediem
[link] => Carpediem
[durum] => 1
[visible] => 1
[lft] => 14
[rgt] => 15
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 15
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[3] => Array
(
[id] => 408
[name] => Kaya Güneri V
[link] => Kaya-Guneri-V
[durum] => 1
[visible] => 1
[lft] => 16
[rgt] => 17
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 17
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[4] => Array
(
[id] => 409
[name] => Take it easier
[link] => Take-it-easier
[durum] => 1
[visible] => 1
[lft] => 18
[rgt] => 19
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 21
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
[1] => Array
(
[id] => 404
[name] => İnşaa Halindeki Projeler
[link] => Insaa-Halindeki-Projeler
[durum] => 0
[visible] => 0
[lft] => 21
[rgt] => 24
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 35
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 410
[name] => SeaWide
[link] => SeaWide
[durum] => 1
[visible] => 1
[lft] => 22
[rgt] => 23
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 19
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
)
)
[3] => Array
(
[id] => 412
[name] => Yat Bakım & Onarım
[link] => Yat-Bakim-Onarim
[durum] => 1
[visible] => 1
[lft] => 26
[rgt] => 45
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 29
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 417
[name] => Ahşap
[link] => Ahsap
[durum] => 0
[visible] => 0
[lft] => 27
[rgt] => 32
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 420
[name] => Gövde
[link] => Govde
[durum] => 1
[visible] => 1
[lft] => 28
[rgt] => 29
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[1] => Array
(
[id] => 421
[name] => İç tasarım
[link] => Ic-tasarim
[durum] => 1
[visible] => 1
[lft] => 30
[rgt] => 31
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
[1] => Array
(
[id] => 418
[name] => Komposit
[link] => Komposit
[durum] => 0
[visible] => 1
[lft] => 33
[rgt] => 38
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 422
[name] => Gövde
[link] => Govde
[durum] => 1
[visible] => 1
[lft] => 34
[rgt] => 35
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[1] => Array
(
[id] => 423
[name] => İç tsarım
[link] => Ic-tsarim
[durum] => 1
[visible] => 1
[lft] => 36
[rgt] => 37
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
[2] => Array
(
[id] => 419
[name] => Çelik
[link] => Celik
[durum] => 0
[visible] => 1
[lft] => 39
[rgt] => 44
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 424
[name] => Gövde
[link] => Govde
[durum] => 1
[visible] => 1
[lft] => 40
[rgt] => 41
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[1] => Array
(
[id] => 425
[name] => İç tasarım
[link] => Ic-tasarim
[durum] => 1
[visible] => 1
[lft] => 42
[rgt] => 43
[lang_id] => 1
[menu_id] => 10
[slug] => comp_empty
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
)
)
[4] => Array
(
[id] => 396
[name] => Aksesuarlar
[link] => Aksesuarlar
[durum] => 1
[visible] => 1
[lft] => 46
[rgt] => 47
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 5
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[5] => Array
(
[id] => 395
[name] => Brokerlik
[link] => Brokerlik
[durum] => 1
[visible] => 1
[lft] => 48
[rgt] => 49
[lang_id] => 1
[menu_id] => 10
[slug] => comp_category_blog
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
[6] => Array
(
[id] => 397
[name] => İletişim
[link] => Iletisim
[durum] => 1
[visible] => 1
[lft] => 50
[rgt] => 53
[lang_id] => 1
[menu_id] => 10
[slug] => comp_contact
[user_level] => 0
[page_id] =>
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
[children] => Array
(
[0] => Array
(
[id] => 427
[name] => deneme
[link] => deneme
[durum] => 0
[visible] => 1
[lft] => 51
[rgt] => 52
[lang_id] => 1
[menu_id] => 10
[slug] => comp_content
[user_level] => 0
[page_id] => 37
[target] => _parent
[nolink] => 0
[default] => 0
[usort] =>
[search] => 0
)
)
)
)
$值[ '孩子'] = $這 - > visibleCheck($值[ '孩子']);這工作。 –