1 $city = Array
2 (
3 Array
4 (
5 'city_id' => "1",
6 'city_name' => "全国",
7 'ename' => "QuanGuo",
8 'letter' => "Q",
9 'city_content' => "ADSFADSFA",
10 'order_desc' => "1",
11 'display' => "1",
12 'short_description' => "ADSFADF",
13 'keyword' => 'AF,ASDF,ADF',
14 'create_name' =>"",
15 'create_time' => ""
16 ),
17 Array
18 (
19 'city_id' => "9",
20 'city_name' => "台州",
21 'ename' => "TaiZhou",
22 'letter' => "T",
23 'city_content' => "AAAA",
24 'order_desc' => "AAA",
25 'display' => "1",
26 'short_description' => "AAA",
27 'keyword' => "AAA",
28 'create_name' => "xiaozi",
29 'create_time' => "1310525878"
30 ),
31 Array
32 (
33 'city_id' => "10",
34 'city_name' => "杭州",
35 'ename' => "hangzhou",
36 'letter' => "H",
37 'city_content' => "asdf",
38 'order_desc' => "2",
39 'display' => "1",
40 'short_description' => "sdfa",
41 'keyword' => "s",
42 'create_name' => "xiaozi",
43 'create_time' => "1310526071"
44 ),
45 Array
46 (
47 'city_id' => "11",
48 'city_name' => "ASDFASDFADSF",
49 'ename' => "ASDFASDFASDF",
50 'letter' => "T",
51 'city_content' => "222ss",
52 'order_desc' => "22",
53 'display' => "1",
54 'short_description' => "22",
55 'keyword' => "ss",
56 'create_name' => "zongzi",
57 'create_time' => "1310701443"
58 )
59 )
//处理上面的数组
//获取所有城市,整排
static public function get_all_city($city)
{
if (is_array($city))
{
for ($i=A;$i<=Z;$i++)
{
foreach ($city as $k=>$vo)
{
if ($i == $vo['letter'])
{
$array[$i][$k] = $vo;
}
}
if($i == Z)
{
break;
}
}
}
return $array;
}
$city = get_all_city($city);
Array ( [H] => Array ( [2] => Array ( [city_id] => 10 [city_name] => 杭州 [ename] => hangzhou [letter] => H [city_content] => asdf [order_desc] => 2 [display] => 1 [short_description] => sdfa [keyword] => s [create_name] => xiaozi [create_time] => 1310526071 ) ) [Q] => Array ( [0] => Array ( [city_id] => 1 [city_name] => 全国 [ename] => QuanGuo [letter] => Q [city_content] => ADSFADSFA [order_desc] => 1 [display] => 1 [short_description] => ADSFADF [keyword] => AF,ASDF,ADF, [create_name] => [create_time] => ) ) [T] => Array ( [1] => Array ( [city_id] => 9 [city_name] => 台州 [ename] => TaiZhou [letter] => T [city_content] => AAAA [order_desc] => AAA [display] => 1 [short_description] => AAA [keyword] => AAA [create_name] => xiaozi [create_time] => 1310525878 ) [3] => Array ( [city_id] => 11 [city_name] => ASDFASDFADSF [ename] => ASDFASDFASDF [letter] => T [city_content] => 222ss [order_desc] => 22 [display] => 1 [short_description] => 22 [keyword] => ss [create_name] => zongzi [create_time] => 1310701443 ) ) )
得到了我想要的!