Re: string comparison

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On Jul 13, 2008, at 9:17 AM, Sudhakar wrote:

hi

i am writing a small application where a user enters a phrase in the
textfield and i would like to display all the files present in the root directory which consists of the keyword or keywords entered by the user.

i have used a few comparison functions but i am not getting the expected
result.

I use this script to list archive files from a directory based on keyword. I'd guess a modified version using the keywords from users might work:

// create archives box
				if ($handle = opendir('../diaryarchives/')) {
					while (false !== ($file = readdir($handle))) {
						$pos = strpos($file, diary_);
						$pagemarked = "diary"."_";
						if ($pos !== false) {
//print "$file<br>";
							$file_name = ereg_replace ("$pagemarked","",$file);
							$file_name = ereg_replace (".php","",$file_name);
//print "* $file_name<br>";
//print "$file<br>";
$archive_list_gather[] = '<li><a href="/diaryarchives/'. $file.'">'.$file_name.'</a></li>';
						}
					}
				closedir($handle);
				}
				rsort($archive_list_gather);
				foreach($archive_list_gather as $value) {
					$archive_list .= "$value";
				}
				// build archives box
				$archives_box = '<div id="diary-archives">
<h3 class="side"><img src="/images/h3s_diaryarchives.gif" alt="Diary Archives" width="225" height="20" /></h3>
				<ul>
					'.$archive_list.'
				</ul>
				</div>';
			
				// publish archives box
				$filename = PATHA.'/diaryarchivesbox.php';
				publishpages($archives_box, $filename);


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux