Hi,

This must be a rather dumb question, but I'll ask it anyway.

Me and my friend are making a simple news script for our website, and thus we are not going to use mysql. The idea was to use mod_rewrite for SEO friendly URLs e.g /news/2008/12/25/this-is-the-subject/ (== news.php?y=2008&m=12&d=25&s=this-is-the-subject )
The point is to make the script as light as possible, so which would be better:

1) Use file() to read one file that has all the news (per line), and check each array for the correct news.

2) Make each news a file (e.g [email]2008@12@25@this-is-the-subject.php[/email]). Then read the file names to an array and check each array for the correct news.

Hope that makes some sense. Thanks.

To have less of an impact on the server at runtime I'm guessing 2) would be much better as in 1) you must load the entire history of news items into memory as opposed to about 30 bytes per news item. (Have I interpreted you correctly?)

ob_start("ob_gzhandler"); 
$p = split('/', $_SERVER['SCRIPT_FILENAME']);
	$script_name = $p[count($p)-1];
	$path = str_replace($script_name, '', $_SERVER['SCRIPT_FILENAME']);
	$dir_handle = @opendir($path) or die("Unable to open $path");
Function get_Extension($m_FileName){
 	$path_parts = pathinfo($m_FileName);
 	if ($path_parts["extension"]) {
 		$m_Extension = strtolower($path_parts["extension"]);
 		return(strtoupper($m_Extension));
 		}
 	else { return "unknown"; }
 }
function check_image($filename){
 $temp=strtoupper(get_Extension($filename));
 if(($temp=="NEWS")||($temp=="PHP"))
 return (true);
 else
 return (false);
 }
Function get_Files($path) {
 	if ($handle = opendir($path)) {	
 		while (false !== ($file = readdir($handle))) { 
 		if(!is_dir($file) && substr($file,O,1) != "."){				
				$m_Files[]=$file;
 			}
 		}
 closedir($handle); 
 	}
 if(sizeof($m_Files)>1)
 asort($m_Files);
 return $m_Files;
 }
 $files=get_Files($path); 
 $filter_files=array_filter($files,"check_image");
 $maxnr=sizeof($filter_files)-1;
 sort($filter_files);
for ($i=0;$i<sizeof($filter_files);$i++){
	echo "<a href='$filter_files[$i]'>";
	echo substr($filter_files[$i], 0, strlen($filter_files[$i])-4);
	echo "</a><br />";
 }
closedir($dir_handle); 
ob_flush();
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.