我需要从
下面的数组中获取“ - ”之间的每个字符串array(2) {
[0]=> string(75) "2225-Fried chicks-PTB001-1-potato",
[1]=> string(72) "2226-Fried pig-PTB002-3-potato" }
所以我可以把它分解为:
$id=2225;
$food=Fried chicks;
$barode= PTB001;
$qty=1;
$salad=potato;
什么是紧张的方式?
答案 0 :(得分:5)
foreach ($array as $a) {
list($id, $food, $barode, $qty, $salad) = explode('-', $a);
}