Saturday, 15 February 2014

Get Data from Array PHP -


I can not retrieve my data from an array, it only shows an empty list of 3 list items from my list I run my foreach loop.

Array ([1] => Array ([ID] => 10 [orderinfo] =

Array [User ID] => 210 [Date] => 2013-06-20 13:46:27) [2] => Hey ([ID] => 18 [orderinfo] => Hello [Userid] => 210 [date] = > 2013-06-20 15:04:58) [3] = & gt; Array ([ID] => 19 [orderinfo] => {"Order": [{"Id": "2", "name": "basil cress", "qty": "1"}, {"id": "4", "name": "Sakura mix", "qty": "1"}, { {"Id": "28", "name": "celery", "qty": 2}, {"id": "6", "name": "bettot shoots", " Id ":" 24 "," name ":" orange capsicum "," qty ":" 1 "}]} [user id] => 210 [date] => 2013-06-20 15

My code so far ..

  foreach ($ itemdata) $ Item) $ $ orderinfo = json_decode ($ item- & gt; orderinto, true); $ orderitem [] = array ('date' => gt; item- & gt; date, 'product name' = & gt; $ Orderinfo ['name'], 'productqty' = & gt; $ orderinfo ['qty'],);} echo "prefix"; print_r ($ orderdata); echo "& lt; / Pre>???? & Gt; & lt ;? php foreach (as the $ OrderTrader $ OrderType)?    

Try to declare your array before the loop in this way: Are you already doing this? $ formitem = array (foreign) Currency ($ orderdata $ as item) {$ commandinfo = json_decode ($ item-> orderinto, true); $ Orderitem [] = array ('date' => date item- & gt; date, Product name '= & gt; $ orderinfo [' name '],' productqty '= & gt; $ orderinfo [' qty '],);}

You can also try to populate your array differently, such as:

  array_push ($ ordireme, array ('date' = & gt; $ item - & Gt; date, 'product name' = & gt; $ orderinfo ['name'], 'product tax' => $ order infra ['qty'],));    

No comments:

Post a Comment