This article mainly introduces two methods for implementing stepless recursive classification in PHP, which has good reference value. Next, let's take a look at the small series. This article mainly introduces two methods for implementing stepless recursive classification in PHP, which has good reference value. Let's take a look at it with the small editor.
For more information, see the code:
/*** Stepless recursive classification TP framework * @ param int $ assortPid parent id of the category to be queried * @ param mixed $ delimiter between the upper and lower levels of the tag * @ return string $ tree returned classification tree structure result **/function recursiveAssort ($ assortPid, $ tag = '') {$ assort = M ('goods _ class')-> where (" class_pid = $ assortPid ")-> field ('class _ id, class_name ')-> select (); foreach ($ assort as $ value) {$ tree. =''. $ Tag. $ value ['class _ name'].''; $ Tree. = recursiveAssort ($ value ['class _ id'], $ tag. 'category');} return $ tree ;}
/*** Use php reference to pass the CI framework **/public function get_access () {$ access = array (); $ field = 'id, pid, method, name, description '; $ q_access = $ this-> db-> select ($ field)-> get ('access'); $ q_result = $ q_access-> result_array (); if (! Empty ($ q_result) {$ items = array (); foreach ($ q_result as $ value) {$ items [$ value ['id'] = $ value ;} foreach ($ items as $ key => $ item) {if ($ item ['pid '] = 0) {$ access [] = & $ items [$ key];} else {$ items [$ item ['pid '] ['sub _ access'] [] = & $ items [$ key] ;}} return $ access ;}
The above are two methods and techniques for implementing stepless recursive classification in PHP. For more information, see PHP Chinese website (www.php1.cn )!