A php unlimited classification method that I used a long time ago uses a recursive approach. Here I will share with you $ data is the classification data retrieved from the database, and $ pid is the parent classification id, $ level is the classification level, which is limited to 10. $ keyword is the classification name funvelgencate ($ data, $ pid0, $ level0, $ keyword) {if ($ level
A php unlimited classification method that has been used a long time ago adopts a recursive approach. Here we will share with you the // $ data for the classification data retrieved from the database, $ pid is the upper-level category id, $ level is the classification level, which is limited to 10 levels, $ keyword is the classification name function genCate ($ data, $ pid = 0, $ level = 0, $ keyword) {if ($ level =
A php unlimited classification method that I used a long time ago uses recursive methods. Here I will share it with you.
// $ Data is the classification data retrieved from the database, $ pid is the upper-level category id, $ level is the classification level, which is limited to 10, $ keyword is the classification name
Function genCate ($ data, $ pid = 0, $ level = 0, $ keyword) {if ($ level = 10) break; $ l = str_repeat ("", $ level); $ l = $ l. 'callback'; static $ arrcat = array (); $ arrcat = empty ($ level )? Array (): $ arrcat; foreach ($ data as $ k => $ row) {if ($ row ['pid '] = $ pid) {$ row [$ keyword] = $ l. $ row [$ keyword]; $ row ['level'] = $ level; $ arrcat [] = $ row; genCate ($ data, $ row ['id'], $ level + 1, $ keyword) ;}return $ arrcat ;}