php - How to find strings between "-" in array -
i need each string between "-" array below
array(2) { [0]=> string(75) "2225-fried chicks-ptb001-1-potato", [1]=> string(72) "2226-fried pig-ptb002-3-potato" }
so can explode to:
$id=2225; $food=fried chicks; $barode= ptb001; $qty=1; $salad=potato;
what fastes way?
foreach ($array $a) { list($id, $food, $barode, $qty, $salad) = explode('-', $a); }
php arrays
No comments:
Post a Comment