如何在此数组中找到子项的父名称?

时间:2014-01-29 11:42:51

标签: php arrays

如何将父ID的名称打印为子ID?

Computer

Computer->Laptop

Computer->Laptop->Sony

Computer->Laptop->Apple

Computer->Laptop->Apple->Macbook Pro

Computer->Laptop->Apple->Macbook Air


[0] => stdClass Object
    (
        [id] => 75
        [pid] => 0
        [nama] => Computer
        [deskripsi] => All About Computer
        [status] => 1
        [keyword] => computer,pc,personal pc
        [tag] => computer,pc,personal pc
        [imgurl] => 
        [bahasa] => en
        [posisi] => 0
    )

[1] => stdClass Object
    (
        [id] => 76
        [pid] => 75
        [nama] => Laptop
        [deskripsi] => All About Laptop Various Brands
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 1
    )

[2] => stdClass Object
    (
        [id] => 82
        [pid] => 76
        [nama] => Sony
        [deskripsi] => All product Sony Laptop
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 2
    )

[3] => stdClass Object
    (
        [id] => 77
        [pid] => 76
        [nama] => Apple
        [deskripsi] => All About Apple Product
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 3
    )

[4] => stdClass Object
    (
        [id] => 78
        [pid] => 77
        [nama] => Macbook Pro
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 4
    )

[5] => stdClass Object
    (
        [id] => 79
        [pid] => 78
        [nama] => Retina Display
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 5
    )

[6] => stdClass Object
    (
        [id] => 81
        [pid] => 77
        [nama] => Macbook Air
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 6
    )

[7] => stdClass Object
    (
        [id] => 83
        [pid] => 76
        [nama] => Leonovo
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] =>
        [bahasa] => en
        [posisi] => 7
    )

[8] => stdClass Object
    (
        [id] => 80
        [pid] => 0
        [nama] => Perlengkapan
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 8
    )

[9] => stdClass Object
    (
        [id] => 84
        [pid] => 80
        [nama] => Processor
        [deskripsi] => 
        [status] => 1
        [keyword] => 
        [tag] => 
        [imgurl] => 
        [bahasa] => en
        [posisi] => 9
    )

0 个答案:

没有答案