carstorm Posted December 7, 2014 Author Share Posted December 7, 2014 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. 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 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); 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
Archived
This topic is now archived and is closed to further replies.