我有一个包含产品的数组(每个产品都有更多数组)
我想获取值[“0_1”]或[“0_2”]? 如果它从0开始,它应该将该产品发送到数组的末尾
array(14) {
["0_1"]=> array(27) {
["files"]=> array(0) { }
["images"]=> array(0) { }
["form_addtocart"]=> string(0) ""
["has_addtocart"]=> bool(false)
["product_flypage"]=> string(137) "index.php?page=shop.product_details&flypage=flypage.tpl&product_id=3299&category_id=88&option=com_virtuemart&Itemid=2"
["product_thumb_image"]=> string(170) "http://www.e-theodoulidis.gr/components/com_virtuemart/show_image_in_imgtag.php?filename=General_Electric_4e5f4d8265044.jpg&newxsize=120&newysize=120&fileout="
["product_full_image"]=> string(108) "http://www.e-theodoulidis.gr/components/com_virtuemart/shop_image/product/General_Electric_4e5f4d8265044.jpg"
["full_image_width"]=> int(1064)
["full_image_height"]=> int(1064)
["product_name"]=> string(42) "General Electric Τηλέγωνο CE 30044"
["product_s_desc"]=> string(0) ""
["product_details"]=> string(43) "Λεπτομέρειες προϊόντος"
["product_rating"]=> string(0) ""
["product_price"]=> string(344) " Καλέστε για Τιμή "
["product_price_raw"]=> array(1) {
["product_price"]=> float(0)
}
["product_sku"]=> string(25) "General Electric CE 30044"
["product_weight"]=> string(6) "0.0000"
["product_weight_uom"]=> string(2) "kg"
["product_length"]=> string(6) "0.0000"
["product_width"]=> string(6) "0.0000"
["product_height"]=> string(6) "0.0000"
["product_lwh_uom"]=> string(6) "inches"
["product_in_stock"]=> string(1) "0"
["product_availability_date"]=> NULL
["product_availability"]=> string(0) ""
["cdate"]=> string(10) "1314868610"
["mdate"]=> string(10) "1314868610"
}
["0_2"]=> array(27) {
["files"]=> array(0) { }
["images"]=> array(0) { }
["form_addtocart"]=> string(0) ""
["has_addtocart"]=> bool(false)
["product_flypage"]=> string(137) "index.php?page=shop.product_details&flypage=flypage.tpl&product_id=7609&category_id=88&option=com_virtuemart&Itemid=2"
["product_thumb_image"]=> string(188) "http://www.e-theodoulidis.gr/components/com_virtuemart/show_image_in_imgtag.php?filename=resized%2FPanasonic________533a7b4f573b0_120x120.jpg&newxsize=120&newysize=120&fileout="
["product_full_image"]=> string(108) "http://www.e-theodoulidis.gr/components/com_virtuemart/shop_image/product/Panasonic________533a7b4f5cba6.jpg"
["full_image_width"]=> int(530)
["full_image_height"]=> int(403)
["product_name"]=> string(39) "Panasonic Τηλέφωνο KX-TS560EX2B"
["product_s_desc"]=> string(0) ""
["product_details"]=> string(43) "Λεπτομέρειες προϊόντος"
["product_rating"]=> string(0) ""
["product_price"]=> string(339) " Καλέστε για Τιμή "
["product_price_raw"]=> array(1) {
["product_price"]=> float(0)
}
["product_sku"]=> string(22) "Panasonic KX-TS560EX2B"
["product_weight"]=> string(6) "0.0000"
["product_weight_uom"]=> string(2) "kg"
["product_length"]=> string(6) "0.0000"
["product_width"]=> string(6) "0.0000"
["product_height"]=> string(6) "0.0000"
["product_lwh_uom"]=> string(6) "inches"
["product_in_stock"]=> string(1) "0"
["product_availability_date"]=> NULL
["product_availability"]=> string(0) ""
["cdate"]=> string(10) "1396341583"
["mdate"]=> string(10) "1426577025"
}
}
答案 0 :(得分:2)
左边的那些(例如“0_1”)是数组键,值是右边的值。
要获得密钥,请使用:
$arrayOfKeys = array_keys($array)
或迭代每个项目,使用:
foreach ($array as $key => $value) { }