Creating plugin using simple_html_dom parser?

Maybe I’m missing something, but in your first print_r($articles), the global variable $articles is in the scope of the getArticles() function, so we’re all good there. But, in your second print_r($articles), which is happening after the closing brace of the getArticles() function declaration, $articles has not been globalized. So, it’s just set to the empty array.

Doing a global $articles prior to your second print_r($articles) should give you the results.