[英]Get values from multidimensional array PhP
I have an array with products (each product has more arrays) 我有一个带有产品的阵列(每个产品都有更多的阵列)
I want to get the values ["0_1"] or ["0_2"]? 我想获取值[“ 0_1”]或[“ 0_2”]? If it starts with 0 it should send that product to the end of the array 如果以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"
}
}
Those on the left (eg. "0_1") are the array keys, and the values are the ones on the right. 左边的那些(例如“ 0_1”)是阵列键,值是右边的。
To get just the keys, use: 要仅获取密钥,请使用:
$arrayOfKeys = array_keys($array)
or to iterate over each item, use: 或要遍历每个项目,请使用:
foreach ($array as $key => $value) { }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.