把好几个URL 分门别类
$str = "
3gp|魔侠传之唐吉可德01|176x144|http://www.xunlei.com/01.3gp@
3gp|魔侠传之唐吉可德02|176x144|http://www.xunlei.com/02.3gp@
3gp|魔侠传之唐吉可德03|176x144|http://www.xunlei.com/03.3gp@
mp4|魔侠传之唐吉可德01|176x400|http://www.xunlei.com/01.mp4@
mp4|魔侠传之唐吉可德02|176x400|http://www.xunlei.com/02.mp4
";
$arr = explode('@',$str);
foreach($arr as $k=>$v) {
$arr1 = explode("|",$v);
$arr2[trim($arr1[0])][] = array(
'title'=>$arr1[1],
'fbl'=>$arr1[2],
'url'=>$arr1[3]
);
}
echo "<pre>";
print_r($arr2);
echo "</pre>";
结果:
Array
(
[3gp] => Array
(
[0] => Array
(
[title] => 魔侠传之唐吉可德01
[fbl] => 176x144
[url] => http://www.xunlei.com/01.3gp
)
[1] => Array
(
[title] => 魔侠传之唐吉可德02
[fbl] => 176x144
[url] => http://www.xunlei.com/02.3gp
)
[2] => Array
(
[title] => 魔侠传之唐吉可德03
[fbl] => 176x144
[url] => http://www.xunlei.com/03.3gp
)
)
[mp4] => Array
(
[0] => Array
(
[title] => 魔侠传之唐吉可德01
[fbl] => 176x400
[url] => http://www.xunlei.com/01.mp4
)
[1] => Array
(
[title] => 魔侠传之唐吉可德02
[fbl] => 176x400
[url] => http://www.xunlei.com/02.mp4
)
)
)