TransWikia.com

Duda recorrer un multiarray

Stack Overflow en español Asked by Norbey Martinez on October 15, 2020

Tengo el siguiente array

object(stdClass)#6 (67) {
  ["id"]=>
  int(3302)
  ["name"]=>
  string(29) "Premium Whey Protein 5 Libras"
  ["slug"]=>
  string(29) "premium-whey-protein-5-libras"
  ["permalink"]=>
  string(68) "https://nutrafitcolombia.com/producto/premium-whey-protein-5-libras/"
  ["date_created"]=>
  string(19) "2020-10-05T14:22:04"
  ["date_created_gmt"]=>
  string(19) "2020-10-05T19:22:04"
  ["date_modified"]=>
  string(19) "2020-10-13T08:05:37"
  ["date_modified_gmt"]=>
  string(19) "2020-10-13T13:05:37"
  ["type"]=>
  string(8) "variable"
  ["status"]=>
  string(7) "publish"
  ["featured"]=>
  bool(false)
  ["catalog_visibility"]=>
  string(7) "visible"
  ["description"]=>
  string(895) "producto descripción"
  ["short_description"]=>
  string(724) "<p><span class="bnf">BENEFICIOS</span></p>"
  ["sku"]=>
  string(0) ""
  ["price"]=>
  string(6) "174900"
  ["regular_price"]=>
  string(0) ""
  ["sale_price"]=>
  string(0) ""
  ["date_on_sale_from"]=>
  NULL
  ["date_on_sale_from_gmt"]=>
  NULL
  ["date_on_sale_to"]=>
  NULL
  ["date_on_sale_to_gmt"]=>
  NULL
  ["on_sale"]=>
  bool(true)
  ["purchasable"]=>
  bool(true)
  ["total_sales"]=>
  int(1)
  ["virtual"]=>
  bool(false)
  ["downloadable"]=>
  bool(false)
  ["downloads"]=>
  array(0) {
  }
  ["download_limit"]=>
  int(-1)
  ["download_expiry"]=>
  int(-1)
  ["external_url"]=>
  string(0) ""
  ["button_text"]=>
  string(0) ""
  ["tax_status"]=>
  string(4) "none"
  ["tax_class"]=>
  string(0) ""
  ["manage_stock"]=>
  bool(false)
  ["stock_quantity"]=>
  NULL
  ["stock_status"]=>
  string(7) "instock"
  ["backorders"]=>
  string(2) "no"
  ["backorders_allowed"]=>
  bool(false)
  ["backordered"]=>
  bool(false)
  ["sold_individually"]=>
  bool(false)
  ["weight"]=>
  string(5) "0.368"
  ["dimensions"]=>
  object(stdClass)#8 (3) {
    ["length"]=>
    string(0) ""
    ["width"]=>
    string(0) ""
    ["height"]=>
    string(0) ""
  }
  ["shipping_required"]=>
  bool(true)
  ["shipping_taxable"]=>
  bool(false)
  ["shipping_class"]=>
  string(0) ""
  ["shipping_class_id"]=>
  int(0)
  ["reviews_allowed"]=>
  bool(false)
  ["average_rating"]=>
  string(4) "0.00"
  ["rating_count"]=>
  int(0)
  ["related_ids"]=>
  array(5) {
    [0]=>
    int(3012)
    [1]=>
    int(1960)
    [2]=>
    int(3027)
    [3]=>
    int(2398)
    [4]=>
    int(1845)
  }

  ["meta_data"]=>
  array(4) {
    [0]=>
    object(stdClass)#15 (3) {
      ["id"]=>
      int(33994)
      ["key"]=>
      string(21) "_selectproduct_layout"
      ["value"]=>
      string(1) "0"
    }
    [1]=>
    object(stdClass)#16 (3) {
      ["id"]=>
      int(33995)
      ["key"]=>
      string(29) "woolentor_cart_custom_content"
      ["value"]=>
      string(0) ""
    }
    [2]=>
    object(stdClass)#17 (3) {
      ["id"]=>
      int(33996)
      ["key"]=>
      string(15) "_saleflash_text"
      ["value"]=>
      string(0) ""
    }
   
    [3]=>
    object(stdClass)#30 (3) {
      ["id"]=>
      int(34006)
      ["key"]=>
      string(10) "_id_alegra"
      ["value"]=>
      string(11) "PRWP5LIBRAS"
    }
  }
}

pero no se como acceder a la posición 3 para poder obtener el valor del id_alegra.

lo intente realizar de la siguiente forma pero no estoy seguro

foreach($products as $product){

$_id_alegra = $product->_id_alegra;


//recorremos el array donde se encuentra los valores de Alegra para traer el codigo de barras
 foreach($items_origin as $item){
    if(isset($item['key'])=='barcode'){
        $valor_barra= $item['value'];
    }
 }



$search_item = reset($search_item);

}

me pueden ayudar a solucionar esta duda

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP