selenin Posted June 10, 2010 Share Posted June 10, 2010 Hello, now I try it the other way, because my script is not working in IE with a jquery function and jquery I don't know, was already happy that I made it for Firefox, now I found out what's not working and have this little question, if I can make the echo out of the foreach function with all the values, my code: $search->setsearchname($_POST['queryString']); $results = $search->results (); $i = 0; foreach ($results as $res) { echo "<li> <a href='suggest.php?mid=".$res->imdbid()."'>".$res->title()." (".$res->year().")</li>"; $i++; if ($i > 11) break; } Now I just need the echo out of the foreach with all values but don't know how to make it, if it's even possible Link to comment https://forums.phpfreaks.com/topic/204425-foreach-question/ Share on other sites More sharing options...
jcbones Posted June 10, 2010 Share Posted June 10, 2010 Does $search->results() return a simple array, or multi-dimensional array? Link to comment https://forums.phpfreaks.com/topic/204425-foreach-question/#findComment-1070522 Share on other sites More sharing options...
jonsjava Posted June 10, 2010 Share Posted June 10, 2010 foreach isn't the best method for what you are doing: <?php $search->setsearchname($_POST['queryString']); $results = $search->results (); for ($i=0;$i<11;$i++){ echo "<li> <a href=\"suggest.php?mid=".$res->imdbid()."\">".$res->title()." (".$res->year()."</a></li>"; } Link to comment https://forums.phpfreaks.com/topic/204425-foreach-question/#findComment-1070523 Share on other sites More sharing options...
selenin Posted June 10, 2010 Author Share Posted June 10, 2010 jonsjava it's not working, now it doesn't work in Firefox even, I don't know what's kind of array $results is that's what I get a part of: array(20) { [0]=> object(imdb)#3 (82) { ["version"]=> string(5) "2.0.0" ["months:protected"]=> array(12) { ["January"]=> string(2) "01" ["February"]=> string(2) "02" ["March"]=> string(2) "03" ["April"]=> string(2) "04" ["May"]=> string(2) "05" ["June"]=> string(2) "06" ["July"]=> string(2) "07" ["August"]=> string(2) "08" ["September"]=> string(2) "09" ["October"]=> string(2) "10" ["November"]=> string(2) "11" ["December"]=> string(2) "12" } ["imdbsite"]=> string(13) "akas.imdb.com" ["pilotsite"]=> string(17) "www.moviepilot.de" ["pilot_apikey"]=> string(30) "50714a0681af531bc7cbb7355521b2" ["pilot_imdbfill:protected"]=> int(0) ["cachedir"]=> string(58) "/home/selenin/public_html/moviecommunity/imdbsearch/cache/" ["usecache"]=> bool(true) ["storecache"]=> bool(true) ["usezip"]=> bool(true) ["converttozip"]=> bool(true) ["cache_expire"]=> int(3600) ["photodir"]=> string(9) "./images/" ["photoroot"]=> string(9) "./images/" ["imdb_img_url"]=> string(7) "./imgs/" ["imdb_utf8recode"]=> bool(false) ["debug"]=> int(0) ["maxresults"]=> int(20) ["searchvariant"]=> string(0) "" ["lastServerResponse"]=> string(0) "" ["revision"]=> string(3) "362" ["imdbID"]=> string(7) "0955308" ["page"]=> array(23) { ["Title"]=> string(0) "" ["Credits"]=> string(0) "" ["CrazyCredits"]=> string(0) "" ["Amazon"]=> string(0) "" ["Goofs"]=> string(0) "" ["Trivia"]=> string(0) "" ["Plot"]=> string(0) "" ["Synopsis"]=> string(0) "" ["Comments"]=> string(0) "" ["Quotes"]=> string(0) "" ["Taglines"]=> string(0) "" ["Plotoutline"]=> string(0) "" ["Directed"]=> string(0) "" ["Episodes"]=> string(0) "" ["Trailers"]=> string(0) "" ["MovieConnections"]=> string(0) "" ["ExtReviews"]=> string(0) "" ["ReleaseInfo"]=> string(0) "" ["CompanyCredits"]=> string(0) "" ["ParentalGuide"]=> string(0) "" ["OfficialSites"]=> string(0) "" ["Keywords"]=> string(0) "" ["Awards"]=> string(0) "" } ["akas"]=> array(0) { } ["awards"]=> array(0) { } ["countries"]=> array(0) { } ["castlist"]=> array(0) { } ["crazy_credits"]=> array(0) { } ["credits_cast"]=> array(0) { } ["credits_composer"]=> Link to comment https://forums.phpfreaks.com/topic/204425-foreach-question/#findComment-1070530 Share on other sites More sharing options...
jcbones Posted June 11, 2010 Share Posted June 11, 2010 In JonsJava's example, the echo should be. echo "<li> <a href=\"suggest.php?mid=".$results->imdbid()."\">".$results->title()." (".$results->year()."</a></li>"; Dunno if that helps, or not. Link to comment https://forums.phpfreaks.com/topic/204425-foreach-question/#findComment-1070614 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.