This question already has an answer here:
- How can I access an array/object? 3 answers
I have an array:
Array (
[variants] => Array (
[0] => Array (
[barcode] => 610373772697
[compare_at_price] =>
[created_at] => 2015-06-27T01:56:42-07:00
[fulfillment_service] => manual
[grams] => 190
[id] => 3856358467
[inventory_management] => shopify
[inventory_policy] => deny
[option1] => Default Title
[option2] =>
[option3] =>
[position] => 1
[price] => 20.99
[product_id] => 1259972867
[requires_shipping] => 1
[sku] => 1125442
[taxable] => 1
[title] => Default Title
[updated_at] => 2015-06-27T01:56:42-07:00
[inventory_quantity] => 100
[old_inventory_quantity] => 100
[image_id] =>
[weight] => 0.42
[weight_unit] => lb
)
[1] => Array (
[barcode] => 364031530906
[compare_at_price] =>
[created_at] => 2015-06-27T01:56:42-07:00
[fulfillment_service] => manual
[grams] => 131
[id] => 3856359043
[inventory_management] => shopify
[inventory_policy] => deny
[option1] => Default Title
[option2] =>
[option3] =>
[position] => 1
[price] => 17.24
[product_id] => 1259973059
[requires_shipping] => 1
[sku] => 0116350
[taxable] => 1
[title] => Default Title
[updated_at] => 2015-06-27T01:56:42-07:00
[inventory_quantity] => 100
[old_inventory_quantity] => 100
[image_id] =>
[weight] => 0.29
[weight_unit] => lb
)
[2] => Array (
[barcode] => 364031534003
[compare_at_price] =>
[created_at] => 2015-06-27T01:56:43-07:00
[fulfillment_service] => manual
[grams] => 390
[id] => 3856359107
[inventory_management] => shopify
[inventory_policy] => deny
[option1] => Default Title
[option2] =>
[option3] =>
[position] => 1
[price] => 27.74
[product_id] => 1259973123
[requires_shipping] => 1
[sku] => 0116368
[taxable] => 1
[title] => Default Title
[updated_at] => 2015-06-27T01:56:43-07:00
[inventory_quantity] => 100
[old_inventory_quantity] => 100
[image_id] =>
[weight] => 0.86
[weight_unit] => lb
)
)
)
)
And no matter how many For Loops I try, I cannot figure out how to extract the [id] and the [product_id] and pass them to variables using PHP.
My goal is to dump the id and product_id into a mysql database and I once I get the values out I can do that easily.
Can anyone help guide me?
Aucun commentaire:
Enregistrer un commentaire