carstorm Posted December 7, 2014 Author Share Posted December 7, 2014 (edited) To suit my purpose in the end I need it to only need the mod name. How would I go about this? Would I use array_search? I know the function would have to be reworked. Edited December 7, 2014 by carstorm Quote Link to comment https://forums.phpfreaks.com/topic/292935-get-a-value-from-another-website/page/2/#findComment-1498913 Share on other sites More sharing options...
Barand Posted December 7, 2014 Share Posted December 7, 2014 (edited) In which case you would pass the mod name and your array to the function. Make the mod name the index of the array. function getMod($mod, &$modarray) { $page = file_get_contents($modarray[$mod][0]); $posStart = strpos($page, "Newest File: ") + $modarray[$mod][1]; $posStop = strpos($page, "<",$posStart) + $modarray[$mod][2]; $version = substr($page, $posStart, $posStop-$posStart); $output = "<br>{$mod}<br>version $version<br>"; return $output; } $mods = array ( "RailCraft" => array("http://www.curse.com/mc-mods/minecraft/railcraft",23,0), "Tinker's Construct" => array("http://www.curse.com/mc-mods/minecraft/tinkers-construct",31,-4), ); // IF YOU WANT ALL THEN foreach ($mods as $mod => $modArray) { echo getMod($mod, $mods); } // IF YOU WANT ONE THEN echo getMod("RailCraft", $mods); Edited December 7, 2014 by Barand Quote Link to comment https://forums.phpfreaks.com/topic/292935-get-a-value-from-another-website/page/2/#findComment-1498915 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.