refiking Posted June 3, 2011 Share Posted June 3, 2011 I am trying to echo a product id from an array, but can't seem to figure out what I need to do here. Here is what I get when I run the query: Array ( [23{1}17{2}36{3}37{4}24] => Array ( [qty] => 1 [attributes] => Array ( [1] => 17 [2] => 36 [3] => 37 [4] => 24 ) ) [81{1}17{8}50{2}23{3}37{4}24] => Array ( [qty] => 1 [attributes] => Array ( [1] => 17 [8] => 50 [2] => 23 [3] => 37 [4] => 24 ) ) ) 2 8 I am trying to get 23<br>81, basically just the product id (everything before the {). Here is the code that produced the results above: print_r($cart->contents); echo '<br>'; //print_r($order->products); $array = $cart->contents;//$order->products; foreach ($array as $i => $value) { echo $i[0].'<br>'; } Link to comment https://forums.phpfreaks.com/topic/238324-help-parsing-data/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.