Jump to content

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;

}

}

}

 

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.