0

I have an array with products (each product has more arrays)

I want to get the values ["0_1"] or ["0_2"]? If it starts with 0 it should send that product to the end of the array

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"
    }
}
1
  • 2
    if you properly format/indent that dump, each layer of indentation is basically another key to add to your path. and 0_1 in your array is a key, not a value. Commented Mar 30, 2015 at 21:45

1 Answer 1

2

Those on the left (eg. "0_1") are the array keys, and the values are the ones on the right.

To get just the keys, use:

$arrayOfKeys = array_keys($array)

or to iterate over each item, use:

foreach ($array as $key => $value) { }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.