Функция
function parse($name){
$array = array(
'/\./' =>'',
'/( feat)(.*)/' =>'',
'/( Ft)(.*)/' =>'',
'/( ft)(.*)/' =>'',
'/( Feat)(.*)/' =>'',
'/( pres)(.*)/' =>'',
'/( Pres)(.*)/' =>'',
'/( vs)(.*)/' =>'',
'/( Vs)(.*)/' =>''
);
$artist = preg_replace(array_keys($array),array_values($array),$name);
$url = 'http://ws.audioscrobbler.com/2.0/?method=artist.getInfo&api_key=57ee3318536b23ee81d6b27e36997cde&artist='.$artist;
$xml = @simplexml_load_file($url);
$poster_def = "<img src=\"images/logo.png\"/>";
if($xml === false || empty($xml->artist->image[3])) {
return $poster_def;
}
$poster_last = $xml->artist[0]->image[3];
$poster_name = uniqid() . ".png";
$poster_dir = "images";
$poster_pach = $poster_dir . "/" . $poster_name;
file_put_contents($poster_pach, file_get_contents($poster_last));
return $xml->artist[0]->image[3];
}
$myVar = parse('cosmic gate');