sandsquid Posted July 27, 2007 Share Posted July 27, 2007 I am slowly learning php, I have a script that I am trying get the output so that I can put it into html format. My problem is, I don't know how to tell php to extract the info from the array for the info I am seeking. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> <title>Product Search</title> </head> <body> <center> <h2>Commission Junction Demo Product Search</h2> <form action="<?php echo $_SERVER['PHP_SELF'] ?>" method="get"> <p><label for="query">Search for </label> <input type="text" name="query" value="<?php echo $_GET['query'] ?>" > <input type="submit" value="Continue →" /></p> </form> </center> <hr> <?php // include class include("nusoap/lib/nusoap.php"); // A search parameter must be passed $query = (isset($_GET['query']) && $_GET['query']) ? $_GET['query'] : ' '; // define your parameters $developerkey = "some number here"; $websiteIdx = "id"; $keyword = $query; $advertiserIds = ""; $serviceableArea = ""; $upcOrIsbnOrEan = ""; $manufacturerName = ""; $advertiserSku = ""; $lowPrice = ""; $highPrice = ""; $currency = ""; $sortBy = ""; $orderIn = ""; $startAt = 0; $maxResultsx = 5; // create a instance of the SOAP client object $soapclient = new soapclient("http://api.cj.com/wsdl/productSearchService.wsdl", 'wsdl'); // set up an array containing input parameters to be passed to the remote procedure $params = array( "developerKey" => $developerkey, "websiteId" => $websiteIdx, "advertiserIds" => "", "keywords" => $query, "serviceableArea" => "", "upcOrIsbnOrEan" => "", "manufacturerName" => "", "advertiserSku" => "", "lowPrice" => "", "highPrice" => "", "currency" => "", "sortBy" => "", "orderIn" => "", "startAt" => $startAt, "maxResults" => $maxResultsx ); // create a proxy so that WSDL methods can be accessed directly $proxy = $soapclient->getProxy(); // invoke the method $result = $proxy->search($params); // print the results as an array //print_r($result); //#$myVar = print_r($result, true); //echo "<pre>$myVar<p>"; //echo "<pre>"; //var_dump($result); //echo "<pre>"; //echo "<hr>"; print "<h3>Your search for '$query' generated $result->totalPossible results</h3>"; // iterate through the results and display them to the user echo '<div id="results">'; echo "<pre>"; var_dump($result); //print_r(array_values($result)); echo "<hr>"; echo "<div style='clear:both'></div>"; echo '</div>' ?> which gives me the output of: array(1) { ["searchReturn"]=> array(4) { ["count"]=> int(5) ["offset"]=> int(0) ["products"]=> array(1) { ["products"]=> array(5) { [0]=> array(10) { ["advertiserId"]=> int(1618930) ["advertiserName"]=> string(37) "Legal Sea Foods Gourmet Gift Division" ["clickUrl"]=> string(138) "http://www.jdoqocy.com/click-2348837-10407384?url=http%3A%2F%2Fshop.legalseafoods.com%2Findex.cfm%2Fpk%2Fproduct%2Fac%2Flist%2Fcid%2F10126" ["currency"]=> string(3) "USD" ["description"]=> string(32) ""THE CAPE COD - GIFT CERIFICATE"" ["imageUrl"]=> string(68) "http://shop.legalseafoods.com/images/thumbnails/Shrimp_ChowderSM.jpg" ["name"]=> string(32) ""THE CAPE COD - GIFT CERIFICATE"" ["price"]=> float(75) ["sku"]=> string(10) ""CAPE COD"" ["upc"]=> string(0) "" } out puts 4 more etc... I need to extract the section ["clickUrl"]=> string(138) "http://www.jdoqocy.com/click-2348837-10407384?url=http%3A%2F%2Fshop.legalseafoods.com%2Findex.cfm%2Fpk%2Fproduct%2Fac%2Flist%2Fcid%2F10126" so that I can put it into html format, I am sure it's something simple that I am over looking, but I am not strong with array's yet.. and have been over the php tut's and help doc's and am not sure which function I need. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Wildbug Posted July 27, 2007 Share Posted July 27, 2007 echo $result["searchReturn"]["products"]["products"][0]["clickURL"]; Quote Link to comment Share on other sites More sharing options...
sandsquid Posted July 27, 2007 Author Share Posted July 27, 2007 worked! Thank you Wildbug! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.