The -3 in substr()'s second parameter will grab the last 3 characters of the string, assuming the 3rd "length" parameter is not given. But in your sample data, the "jpg" is not always at the end of the string. For instance, the last 3 characters of $test[2] will be '/>. (What the -3 really means is to start from the string position index that is 3rd from the end.)
Anyway, if I'm understanding your needs correctly, I'd probably do this (yes, with good ol' preg):
$test = Array();
$test[1]= "some.jpg";
$test[2] = "<img src='some.jpg'/>";
$test[3] = "<img src='some.jpg'/>";
$test[4] = "somepage.txt";
$testtimer = date("s")%count($test)+1;
if(preg_match('#\.jpg($|[\'"])#i', $test[$testtimer]))
{
$get_content = $test[$testtimer];
echo $get_content;
}
else
{
$get_content = file_get_contents($test[$testtimer]);
echo $get_content;
}
All the regex is doing is looking for the (case-insensitive) string ".jpg", where it either appears at the very end of the string or is immediately followed by a single- or double-quote.