Ask a multi-dimensional array recursive search question

Source: Internet
Author: User
Ask a multi-dimensional array recursive lookup question about a data table with an Infinitus category
I classify data tables and generate multi-dimensional arrays for saving.
Function getkind ($ id)
{
If(file_exists(%_g%'cache'%.'kindcache.txt ') // determines whether the category cache exists
$ Str = unserialize(file_get_contents(pai_gw.'cache'{.'kindcache.txt '));
Else
$ Str = $ cache-> outkindcache (0); // generates a category cache.
$ Data = $ this-> getkindcache ($ id, $ str); // search for an array
Return $ data;
}

Function getkindcache ($ id, $ str, $ data1 = array () // recursive function
{
Global $ _ G;
Foreach ($ str as $ k => $ v)
{
If ($ v ['kind'] = $ id)
{
$ Data1 [] = $ v;
}
If (is_array ($ v ['child '])
$ This-> getkindcache ($ id, $ v ['child '], $ data1 );

}
Return $ data1;
}
The above recursive function always returns NULL and cannot save the data I want to return.

The data I want to search is highlighted in red.

Array
(
[0] => Array
(
[Uid] => 2
[Kind] => 0
[Top] => 2
[Pagesize] => 15
[Name] => News
[Sort] => 1
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/2
[Grade] => 1
[Kindtype] => 1
[Child] => Array
(
[0] => Array
(
[Uid] => 1
[Kind] => 2
[Top] => 1
[Pagesize] => 15
[Name] => Product Display
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => product
[Modelname] => Product model
[Template] => product.html
[Templist] => product_list.html
[Tempview] => product_view.html
[Typedir] => http: // localhost/2011-4-30/static/1
[Grade] => 1
[Kindtype] => 1
[Child] => Array
(
[0] => Array
(
[Uid] => 15
[Kind] => 1
[Top] => 1
[Pagesize] => 15
[Name] => Rubber Products
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => product
[Modelname] => Product model
[Template] => product.html
[Templist] => product_list.html
[Tempview] => product_view.html
[Typedir] => http: // localhost/2011-4-30/static/1/15/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] =>
)
)

)

[1] => Array
(
[Uid] => 3
[Kind] => 2
[Top] => 3
[Pagesize] => 30
[Name] => image display
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => images
[Modelname] => image model
[Template] => images.html
[Templist] => images_list.html
[Tempview] => images_view.html
[Typedir] => http: // localhost/2011-4-30/static/3/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] => Array
(
[0] => Array
(
[Uid] => 17
[Kind] => 3
[Top] => 3
[Pagesize] => 15
[Name] => test
[Sort] => 0
[Keywords] = & gt; 1111
[Description] = & gt; 2222
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/3/17/list_1.html
[Grade] => 0
[Kindtype] => 0
[Child] =>
)

[1] => Array
(
[Uid] => 18
[Kind] => 3
[Top] => 3
[Pagesize] => 15
[Name] => test
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/3/18/list_1.html
[Grade] => 0
[Kindtype] => 0
[Child] =>
)

[2] => Array
(
[Uid] => 19
[Kind] => 3
[Top] => 3
[Pagesize] => 15
[Name] => test
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/3/19/list_1.html
[Grade] => 0
[Kindtype] => 0
[Child] =>
)
)

)


Reply to discussion (solution)

[3] => Array
(
[Uid] => 7
[Kind] => 2
[Top] => 2
[Pagesize] => 15
[Name] => French News
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/2/7
[Grade] => 1
[Kindtype] => 1
[Child] =>
)

)

[4] => Array
(
[Uid] => 8
[Kind] => 2
[Top] => 2
[Pagesize] => 15
[Name] => chinese news
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/2/8/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] =>
)

[5] => Array
(
[Uid] => 9
[Kind] => 2
[Top] => 2
[Pagesize] => 15
[Name] => Russian News
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/2/9/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] =>
)

[6] => Array
(
[Uid] => 10
[Kind] => 2
[Top] => 2
[Pagesize] => 15
[Name] => British News
[Sort] => 0
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => news
[Modelname] => news model
[Template] => news.html
[Templist] => news_list.html
[Tempview] => news_view.html
[Typedir] => http: // localhost/2011-4-30/static/2/10/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] =>
)

)

)

[1] => Array
(
[Uid] => 4
[Kind] => 0
[Top] => 4
[Pagesize] => 15
[Name] => information classification
[Sort] => 6
[Keywords] =>
[Description] =>
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => info
[Modelname] => classification model
[Template] => info.html
[Templist] => info_list.html
[Tempview] => info_view.html
[Typedir] => http: // localhost/2011-4-30/static/4/list_1.html
[Grade] => 1
[Kindtype] => 0
[Child] => Array
(
[0] => Array
(
[Uid] => 5
[Kind] => 4
[Top] => 4
[Pagesize] => 15
[Name] => Travel Photography
[Sort] => 0
[Keywords] => Travel Photography
[Description] => Travel Photography
[Enable] => 1
[Html] => 1
[Outlink] =>
[Model] => info

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.