Article into objects
This commit is contained in:
18
index.php
18
index.php
@@ -1,17 +1,11 @@
|
||||
<?php
|
||||
|
||||
include './Article.php';
|
||||
include './RSSArticle.php';
|
||||
include './RSSArticleManager.php';
|
||||
|
||||
$url = "http://fetchrss.com/rss/6213baca199e171a5d6eacc26213babd69097e19dd230f73.xml"; /* insérer ici l'adresse du flux RSS de votre choix */
|
||||
$rss = simplexml_load_file($url);
|
||||
|
||||
$tabArticle = array();
|
||||
foreach ($rss->channel->item as $item){
|
||||
|
||||
$desc = explode("</div>", explode('<div class="content">', $item->description)[1]);
|
||||
|
||||
array_push($tabArticle, new Article($item->title, $desc[0], date_create($item->pubDate), $item->link));
|
||||
}
|
||||
$am = new RSSArticleManager();
|
||||
$tabArticle = $am -> createArticles();
|
||||
$tabArticle = $am -> sortArticles($tabArticle);
|
||||
|
||||
?>
|
||||
|
||||
@@ -27,7 +21,7 @@ foreach ($rss->channel->item as $item){
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
echo sizeof($tabArticle) .' articles<br /><br />';
|
||||
foreach ($tabArticle as $a) {
|
||||
echo $a.'<br />';
|
||||
}
|
||||
|
Reference in New Issue
Block a user