I have an array $cart:
array:1 [
"product" => array:5 [
"product_id" => array:2 [
0 => 2
1 =>
if product_id
is a consistent field for your product
array, you can use its length as an iterator count to perform lookups on the other keys. WARNING this assumes that ALL keys you're using to output into the template have the same length as product_id
, and that each index within each key refers to the same product.
You dont appear to have a key for quantity
so havent populated that field
$ x
PS. unfortunately i am unfamiliar with Laravel syntax, so this is in standard PHP
EDIT
Because it didnt sit right with me to be using that format i have created a converter function that should turn your array into something more manageable
$ x