Jump to content

Get a value from another website?


carstorm

Recommended Posts

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); 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.