I have this function coded to check the status of a Rapidshare link using their API:
function CheckLink($fileid, $filename)
{
$q = file_get_contents("http://api.rapidshare.com/cgi-bin/rsapi.cgi?sub=checkfiles_v1&files=$fileid&filenames=$filename");
$r = explode(",", $q);
switch ($r[4])
{
case 0:
return array('status' => "0", 'desc' => "File not found");
break;
case 1:
return 1;
break;
case 2:
return 1;
break;
case 3:
return array('status' => "0", 'desc' => "Server down");
break;
case 4:
return array('status' => "0", 'desc' => "File marked as illegal");
break;
case 5:
return array('status' => "0", 'desc' => "Anonymous file locked");
break;
case 6:
return 1;
break;
default:
return array('status' => "0", 'desc' => "Unknown error");
}
}
If the function returns 1, the file is alive. If it returns an array it means the file is dead. The array it returns is the status code (0 because it's dead) and the error message to be shown to the user.
Now, I have this code in index.php:
if(is_array($var = CheckLink($match[1], $match[2])))
{
echo $var[1];
}
What I'm trying to do is check if the result of the function is an array (meaning the link is dead) and if it is, echo the error message to the user. But it's not working, I get no PHP error and it's not echo'ing anything to the page.
Any help on this? Thanks. :)