There is such an array:

array(11) { [0]=> array(4) { [0]=> string(3) "106" [1]=> string(9) "Prod_code" [2]=> string(12) "125126515621" [3]=> string(3) "198" } [1]=> array(4) { [0]=> string(3) "167" [1]=> string(9) "Prod_code" [2]=> string(8) "14425dsf" [3]=> string(3) "200" } [2]=> array(4) { [0]=> string(3) "106" [1]=> string(9) "Prod_code" [2]=> string(8) "1231231c" [3]=> string(3) "199" } [3]=> array(4) { [0]=> string(3) "106" [1]=> string(9) "Prod_text" [2]=> string(8) "Товар 11" [3]=> string(3) "198" } [4]=> array(4) { [0]=> string(3) "106" [1]=> string(9) "Prod_text" [2]=> string(8) "Товар 12" [3]=> string(3) "197" } [5]=> array(4) { [0]=> string(3) "106" [1]=> string(9) "Prod_text" [2]=> string(8) "Товар 13" [3]=> string(3) "199" } [6]=> array(4) { [0]=> string(3) "106" [1]=> string(10) "Prod_price" [2]=> string(6) "100000" [3]=> string(3) "198" } [7]=> array(4) { [0]=> string(3) "106" [1]=> string(10) "Prod_price" [2]=> string(6) "105000" [3]=> string(3) "197" } [8]=> array(4) { [0]=> string(3) "106" [1]=> string(10) "Prod_price" [2]=> string(6) "110000" [3]=> string(3) "199" } [9]=> array(4) { [0]=> string(3) "167" [1]=> string(9) "Prod_text" [2]=> string(13) "123fasdsdfasd" [3]=> string(3) "200" } [10]=> array(4) { [0]=> string(3) "167" [1]=> string(10) "Prod_price" [2]=> string(3) "210" [3]=> string(3) "200" } } 

At the exit you need to get the following result: Article: 125126515621 Item: Item 11 Price: 100000, etc.

  • one
    format the array, print_r do something, and the code by which you tried to show it. - zb '
  • one
    And why "Item 11", and not "Item 12"? Again, "guess what I need and tell me how to do it"? - alexlz
  • Allow, receive. - pincher1519
  • @alexlz I figured out what he wants))) and why Product 11 is there))) I would say that the wrong approach, form an array differently ... - IVsevolod

1 answer 1

 foreach ($data as $key){ // CODE echo $key['name']; } 

That's all)

  • So, I started to understand, it turned out that he wants: 1) if $key[1] == "Prod_code" then this is article 2) if $key[1] == "Prod_text" then this is Title 3) if $key[1] == "Prod_price" then this is Price 4) and they are all linked by the same $ key [3] - IVsevolod
  • Yes, they are related. I solved the problem by setting up three arrays when sampling from byzy. 1st with Articles, 2nd with Goods, 3rd with Prices. In the 4th, I wrote down the indices and keys ... then I went through the array and xsly there is the price and the name I check the article, then it can not exist, then I take it and add zeros ... Thank you all, everyone is free;) - Sergey_misterio