kellz Posted November 1, 2007 Share Posted November 1, 2007 hey all Soo i spent ages thinking of a way i can make a site search function without using SQL and i did it yayness to me! here it is: <?php $search = "search term"; $x=0; foreach (glob('*.html') as $file) { $data = file($file); $currentfile = $file; foreach ($data as $line) { if (stristr($line, $search)) { if ($x != 1) print "Your keyword '$search' has been located. A section of the text containing that keyword and the URL to that page are listed below."."<br /><br />\n";$x=1; preg_match_all ("/(" . $search . ")/is", $line, $array); for ($i=0; $i < sizeof ($array[0]); $i++) { $line = str_replace($array[0][$i], '<i style="color:#339900;">' . $array[0][$i] . "</i>", $line); } echo "URL: $currentfile <br />Preview: <br />". $line . "<br /><hr />\n"; } } } ?> I guess readers already understand the code? lol anyway yesh i am kinda crappy and I know it could do with a face lift so what else could i do? is there something i "should" be using instead of something i am using? ps: Happy halloween! wooo i got candy! and money (ofcourse) never to old for it! Link to comment https://forums.phpfreaks.com/topic/75591-searching-website-for-keywords/ Share on other sites More sharing options...
d.shankar Posted November 1, 2007 Share Posted November 1, 2007 Try this for free http://search.freefind.com This is free and you can use it for your site. Link to comment https://forums.phpfreaks.com/topic/75591-searching-website-for-keywords/#findComment-382578 Share on other sites More sharing options...
kellz Posted November 1, 2007 Author Share Posted November 1, 2007 thx.. but there's no fun in using someone else's work^^ Link to comment https://forums.phpfreaks.com/topic/75591-searching-website-for-keywords/#findComment-382814 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.