我有這行字符串的PHP爆炸並投入陣列
Fruits-banana|apple|orange:Food-fries|sausages:Desserts-ice cream|apple pie
的:
(結腸)是主要主題的隔膜和|
是對於不同類型的子主題隔板。
我試圖引爆出來,放入數組,我需要的結果是要顯示這樣的事情在一個下拉菜單: -
Fruits banana apple orange Food fries sausages
$result=explode(":",$data);
foreach($result as $res) {
$sub_res[]=explode("-",$res);
}
foreach($sub_res as $sub) {
//echo $sub[1]."<br>"; Over here, I can get the strings of [0]=>banana|apple|orange, [1]=>sausages|fries,
// I explode it again to get each items
$items[]=explode("|",$sub[1]);
$mainCategory[]=$sub[0]; // This is ([0]=>Fruits, ]1]=>Food, [2]=>dessert
// How do I assign the $items into respective categories?
}
謝謝!
你需要子的獨立的2維數組類別? – Kel 2010-10-25 19:07:33
你從哪裏得到那條線? – 2010-10-25 19:14:13
您是否需要爲每種類型的所有或單獨的下拉菜單使用一個下拉菜單? – Jason 2010-10-25 19:20:28