tabURL as $u) { $rss = simplexml_load_file($u); foreach ($rss->channel->item as $item){ $desc = ""; array_push($tabArticle, new RSSArticle($item->title, date_create($item->pubDate), $item->link)); } } return $tabArticle; } public function createNArticles(int $a) : array { $tabArticle = array(); $rtabArticle = array(); foreach ($this->tabURL as $u) { $rss = simplexml_load_file($u); foreach ($rss->channel->item as $item){ $desc = ""; array_push($tabArticle, new RSSArticle($item->title, date_create($item->pubDate), $item->link)); } } for($i = 0; $i < $a; ++$i) { $rtabArticle[$i] = $tabArticle[$i]; } return $rtabArticle; } public function sortArticles(array $a) : array { $tab = $a; usort($tab, function($firstArticle, $secondArticle) { //sorting method of all articles $testA = $firstArticle->getArticleDate(); $testB = $secondArticle->getArticleDate(); if ($testA == $testB) { return 0; } return $testA > $testB ? -1 : 1; }); return $tab; } }