Home > Article > Backend Development > PHP infinite classification to find parent layer function_PHP tutorial
classID classFID className classCount
1 1 0 0 China China 0
2 1 1 Zhejiang 0
3 1 1 Jiangsu 0
4 2 2 Hangzhou 0
5 4 4 West Lake District 0
If
findFather(4,0) show => Hangzhou
findFather(4,1) shows => Zhejiang
findFather(4,2) show => China
findFather(4,3) shows => China -> Zhejiang -> Hangzhou
The code is as follows: