]*>(.*?)<\/\\1>/s'; preg_match_all($reg_exp, $text, $match); foreach ($match[1] as $key=>$val) { if ( preg_match($reg_exp, $match[2][$key]) ) { $array[$val][] = xml2array($match[2][$key]); } else { $array[$val] = $match[2][$key]; } } return $array; } function find_best_image ($search,$section="Books",$locale='US'){ //this is a curl wrapper class that I wrote a while back and is quite usefull for these //kinds of applications. $curl = new curl_inc_1_0; switch ($locale) { case 'DE': $url = "http://webservices.amazon.de/onca/xml";break; case 'CA': $url = "http://webservices.amazon.ca/onca/xml";break; case 'FR': $url = "http://webservices.amazon.fr/onca/xml";break; case 'JP': $url = "http://webservices.amazon.co.jp/onca/xml";break; case 'UK': $url = "http://webservices.amazon.co.uk/onca/xml";break; case 'US': default: $url = "http://webservices.amazon.com/onca/xml";break; }//switch; // You need to leave the following alone for the most part. You CAN change the SubscriptionID // But i'd appreciate it if you just left it set to mine. :) $form_data = array ("Service"=>"AWSECommerceService", "SubscriptionId"=>"05T5C0DJ53HFGKJCK4G2", "AssociateTag"=>"dh0net-20", "Operation"=>"ItemSearch", "Keywords"=>$search, "SearchIndex"=>$section, "ResponseGroup"=>"Medium" ); $response_array = $curl->curl_fetch_array($url,$form_data); // print (""); if (is_array($results['ItemSearchResponse'][0]['Items'][0]['Item'][0] ) ) { return (array("Image"=>$results['ItemSearchResponse'][0]['Items'][0]['Item'][0]['ImageSets'][0]['ImageSet'][0]['SmallImage'][0][URL], "Height"=>$results['ItemSearchResponse'][0]['Items'][0]['Item'][0]['ImageSets'][0]['ImageSet'][0]['SmallImage'][0][Height], "Width"=>$results['ItemSearchResponse'][0]['Items'][0]['Item'][0]['ImageSets'][0]['ImageSet'][0]['SmallImage'][0][Width], "Detail"=>$results['ItemSearchResponse'][0]['Items'][0]['Item'][0]['DetailPageURL'])); }else return(false); }//find_image ?>