[Solved] How to get all images for an artist with Last.fm API (Need examples) PHP


$htmlContent = file_get_contents(‘http://www.last.fm/fr/music/‘.$artist.’/+images’);

// We'll add all the images in this array
$images = array();

// Instantiate a new object of class DOMDocument
$doc = new DOMDocument();

// Load the HTML doc into the object
libxml_use_internal_errors(true);
$doc->loadHTML($htmlContent);
libxml_use_internal_errors(false);

// Get all the IMG tags in the document
$elements = $doc->getElementsByTagName('img');

// If we get at least one result
if($elements->length > 0)
{
   // Loop on all of the IMG tags
   foreach($elements as $element)
   {
      // Get the attribute SRC of the IMG tag (this is the link of the image)
      $src = $element->getAttribute('src');

      if (strlen($src) > 0) {
        // Add the link to the array containing all the links
        array_push($images, $src);
      }

   }

solved How to get all images for an artist with Last.fm API (Need examples) PHP