Array ( [out] => Array ( [count] => 10 [offset] => 0 [products] => Array ( [Product] => Array ( [0] => Array ( [adId] => 1221314 [advertiserId] => 6455 [advertiserName] => Baseball Warehouse [buyUrl] => http://www.tkqlhce.com/click-xxxxxx?url=http%3A%2F%2Fwww.baseballwarehouse.com%2FItemdesc.asp%3Fic%3DSSCGB%26Tp%3D&cjsku=SSCGB [catalogId] => cjo:262 [currency] => USD [description] => The definitive guide to men's collegiate baseball programs in the U.S....Regular Price: $27.95...Baseball Warehouse Price: $24.99 [imageUrl] => http://www.bwimages.net/products/sscgb_s.jpg [inStock] => [isbn] => [manufacturerName] => TheSportSource [manufacturerSku] => [name] => COLLEGE GUIDE BASEBALL [price] => 24.99 [retailPrice] => 0.0 [salePrice] => 0.0 [sku] => SSCGB [upc] => ) [1] => Array ( [adId] => 121212 [advertiserId] => 434234 [advertiserName] => Baseball Warehouse [buyUrl] => http://www.dpbolvw.net/click-xxxxxx?url=http%3A%2F%2Fwww.baseballwarehouse.com%2FItemdesc.asp%3Fic%3DBYBVID%26Tp%3D&cjsku=BYBVID [catalogId] => cjo:262 [currency] => USD [description] => This creative video is geared for all parents and kids who love baseball. This video is comprised of over 30 great drills that can be played in one's own backyard. This is a true baseball lovers delight that parents will use continually as a resource. [imageUrl] => http://www.bwimages.net/products/bybvid_s.jpg [inStock] => [isbn] => [manufacturerName] => YouthSportsClub [manufacturerSku] => [name] => BACKYARD BASEBALL VIDEO [price] => 19.99 [retailPrice] => 0.0 [salePrice] => 0.0 [sku] => BYBVID [upc] => ) ) ) [totalResults] => 130069 ) ) Code (markup): Anybody can help, How I can get the value of this deep array. I just want to take the value Name, descriptiom and price. I have use this foreach still got zero result foreach ($result as $key => $v) { if($key=="products") { foreach ( $v[product] as $a => $b ) { $description =$b[description]; echo "$description"; } } } Code (markup):
Place some "print_r($v);" or "print_r($b);" in the code to be able to see where your pointer currently is and if you need to go deeper.
now let's see.. this is your array: $array = array ( "out" => array ( "count" => "10", "offset" => "0", "products" => array ( "Product" => array ( "0" => array ( "adId" => "1221314", "advertiserId" => "6455", "advertiserName" => "Baseball Warehouse", "buyUrl" => "","http://www.tkqlhce.com/click-xxxxxx?url=http%3A%2F%2Fwww.baseballwarehouse.com%2FItemdesc.asp%3Fic%3DSSCGB%26Tp%3D&cjsku=SSCGB", "catalogId" => "cjo:262", "currency" => "USD", "description" => "The definitive guide to men's collegiate baseball programs in the U.S....Regular Price: $27.95...Baseball Warehouse Price: $24.99", "imageUrl" => "http://www.bwimages.net/products/sscgb_s.jpg", "inStock" => "", "isbn" => "", "manufacturerName" => "TheSportSource", "manufacturerSku" => "", "name" => "COLLEGE GUIDE BASEBALL", "price" => "24.99", "retailPrice" => "0.0", "salePrice" => "0.0", "sku" => "SSCGB", "upc" => "", ), "1" => array ( "adId" => "1221314", "advertiserId" => "6455", "advertiserName" => "Baseball Warehouse", "buyUrl" => "","http://www.tkqlhce.com/click-xxxxxx?url=http%3A%2F%2Fwww.baseballwarehouse.com%2FItemdesc.asp%3Fic%3DSSCGB%26Tp%3D&cjsku=SSCGB", "catalogId" => "cjo:262", "currency" => "USD", "description" => "The definitive guide to men's collegiate baseball programs in the U.S....Regular Price: $27.95...Baseball Warehouse Price: $24.99", "imageUrl" => "http://www.bwimages.net/products/sscgb_s.jpg", "inStock" => "", "isbn" => "", "manufacturerName" => "TheSportSource", "manufacturerSku" => "", "name" => "COLLEGE GUIDE BASEBALL", "price" => "24.99", "retailPrice" => "0.0", "salePrice" => "0.0", "sku" => "SSCGB", "upc" => "", ), ), ), ), ); Code (markup): I used two same product values for this example. So.. for this array you can use this code to print your values // number of products $num_Products = count($array["out"]["products"]["Product"]); for($x = 0; $x < $num_Products; $x++) { echo $array["out"]["products"]["Product"][$x]["description"]."<br>"; echo $array["out"]["products"]["Product"][$x]["name"]."<br>"; echo $array["out"]["products"]["Product"][$x]["price"]."<br>"; echo "<hr>"; } Code (markup): and you will get something like this The definitive guide to men's collegiate baseball programs in the U.S....Regular Price: $27.95...Baseball Warehouse Price: $24.99 COLLEGE GUIDE BASEBALL 24.99 _________________________________________________ The definitive guide to men's collegiate baseball programs in the U.S....Regular Price: $27.95...Baseball Warehouse Price: $24.99 COLLEGE GUIDE BASEBALL 24.99 _________________________________________________ is it that what you want?
foreach ($results['out']['products']['Product'] as $_product_number){ echo "$_product_number[name]<br />"; echo "$_product_number[description]<br />"; echo "$_product_number[price]<br />"; echo '<hr />'; } PHP: