Php implements recursive and unlimited classification methods, and php implements recursive classification. Php implements recursive and unlimited classification methods. php implements recursive classification. This article describes how php implements recursive and unlimited classification. The specific implementation method is as follows: php implements recursive and unlimited classification, and php implements recursive classification.
This example describes how php implements recursion and unlimited classification. The specific implementation method is as follows:
<? Phpecho""; $ Area = array ('id' => 1, 'region' => 'Beijing', 'pid '=> 0 ), array ('id' => 2, 'area '=> 'Guangxi', 'pid '=> 0), array ('id' => 3, 'area '=> 'Guangdong', 'pid '=> 0), array ('id' => 4, 'area' => 'Fujian ', 'pid '=> 0), array ('id' => 11, 'area' => 'chaoyang District ', 'pid' => 1 ), array ('id' => 12, 'area '=> 'haidian District', 'pid '=> 1), array ('id' => 21, 'area '=> 'nanning city', 'pid '=> 2), array ('id' => 45, 'area' => 'Fuzhou city ', 'pid '=> 4), array ('id' => 113, 'area' => 'Asian games cune', 'pid '=> 11 ), array ('id' => 115, 'area '=> 'Olympic cune', 'pid' => 11), array ('id' => 234, 'area '=> 'Wuming County', 'pid '=> 21); function t ($ arr, $ pid = 0, $ lev= 0) {static $ list = array (); foreach ($ arr as $ v) {if ($ v ['pid '] = $ pid) {echo str_repeat ("", $ lev ). $ v ['region']."
"; // Output here, to see the effect $ list [] = $ v; t ($ arr, $ v ['id'], $ lev+ 1 );}} return $ list;} $ list = t ($ area); echo"
"; Print_r ($ list);?>
I hope this article will help you with php programming.
Examples in this article describe how php implements recursion and unlimited classification and share it with you for your reference. The specific implementation method is as follows...