Add an if statement that checks if the result is an array.
if(is_array($json['results']['artistmatches'])) {
foreach ($json['results']['artistmatches']['artist'] as $track)
{
$artist = $track['name'];
$image = $track['image'][3]['#text'];
$url = preg_replace("/ /s","_" , $artist);
if($artist&&$image)
{
include('./artist_short.php');
}
}
} else {
//handle case where the condition doesn't match.
}