PHP Invalid argument supplied for foreach() when getting RSS

Solution:

Since you are dealing with XML content, I found it easier to use SimpleXML instead of DOMDocument. Since each <item> is in the same block as channel you can do a foreach looking for a key of item.

$feed = simplexml_load_file('https://twitrss.me/twitter_search_to_rss/?term=test+this+feed');

foreach ($feed->channel as $row) {
    foreach ($row->children() as $key => $val) {
        if ($key == "item") {
            $ns_dc = $val->children('http://purl.org/dc/elements/1.1/');
            echo $ns_dc->creator;
        }
    }
}

This code outputs the “creator” string you expect.