Jump to content

Need help modify a script to pull articles from a file


ninevolt1

Recommended Posts

Is there any way to modify the below script to get the last five articles? Right now as it is, it opens an html file and displays on my web page the first 5 articles. I have a need where I will want it to display the last 5 articles. The html file is one huge file with many news articles in it. The script knows where each article starts by looking for the "<!--ARTICLE-->" before each article. Any help will be greatly appreciated.

 

 

<?php

        require('news_manager/dconfig.php');

 

$filename = "news_manager/camera_summary2.html";

 

#- open article summaries

if(file_exists($filename)){

$fh = fopen($filename, "r");

$old_news = fread($fh, filesize($filename));

fclose($fh);

}

 

 

#- get first five article

$articles = explode("<!--ARTICLE-->", $old_news);

 

$i=0;

foreach ( $articles as $article ){

if(count($articles)>$i){

if($max_latest >= $i++){

print $article;

}

}

}

 

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.