[Solved] Fatal error: Call to a member function getElementsByTagName() on array


Obviously $songs is an array of divs. If you need just the first one, then use index:

$songs[0]->getElementsByTagName('ul');

It would be a good idea to check if $songs array is not empty before that:

if (!empty($songs)) {
    $songs[0]->getElementsByTagName('ul');
}

Please note that DOMDocument::getElementsByTagName method returns DOMNodeList object which is collection-like. Thus if you want some specific , then you should use DOMNodeList::item method:

$myLists = $songs[0]->getElementsByTagName('ul');

// get only the first UL element
$firstList = $myLists->item(0);
foreach ($firstList->getElementsByTagName('li') as $a) {
    echo $a;
}

// or walk through all of them
foreach ($myLists as $list) {
    foreach ($list->getElementsByTagName('li') as $a) {
        echo $a;
    }
}

solved Fatal error: Call to a member function getElementsByTagName() on array