A netizen wrote a PHP classification program for linking prefectures and cities. You can refer to it.
Write a function to convert the data
代码如下 | 复制代码 |
$array = array( 0=>array("","河北"), 1=>array("","北京"), 2=>array(0,"保定"), 3=>array(1,"海淀"), 4=>array(3,"中关村"), 5=>array(2,"涿州") ); |
After processing, the return is as follows:
Hebei
-Baoding
--Zhuozhou
Beijing
-Haidian
--Zhongguancun
The code is as follows
|
Copy code | ||||
function typeArray($array){ |
$na[$k] = is_numeric($v[0]) ? $na[$v[0]].$k."|" : $k."|";
http://www.bkjia.com/PHPjc/631581.htmlwww.bkjia.comtruehttp: //www.bkjia.com/PHPjc/631581.htmlTechArticleA php classification program for prefecture-city linkage written by a netizen, you can refer to it. Write a function to convert the data. The code is as follows. Copy the code $array = array( 0=array(,Hebei), 1=array(,Beijing),...