[PHP] Searching arrayed file... Suggestions?
Greetings. I have made a try to write a search engine for a site I run. This search iterates through all links which are made up like so: "|BY|EMAIL|CATEGORY|FOLDER/BAND|LINKNAME|LINKURL|". Now, I use the code: if ($txtLinkname=="") return; $logfile="entries.txt"; $file_line = file($logfile); $total_lines = count($file_line); // Start printing the header of the table. The rest is completed, nested // course.. in the incrementation-loop. echo"table width=60% cellpadding=0 border=0 cellspacing=0 align=center"; echo"trtd width=100% valign=top align=left"; for($i=($total_lines-1); 0 = $i; $i--) { $line[] = $file_line[$i]; } echo "pbSearching for links containing $txtLinkname...br"; echo "hr noshade"; echo "/b"; for ($i=0; $i $total_lines; $i++){ $line_array = explode("|",$line[$i]); $swhere=strtolower($line_array[5]); $swhat=strtolower($txtLinkname); $pos = strpos ($swhere, $swhat); if ($pos0) { // not found }else if (($pos1) (!empty($pos))) { $found++; echo"bName:/b $line_array[1]br\n"; echo"bEmail:/b a href=\"mailto:$line_array[2]\"$line_array[2]/abr\n"; echo"bCategory:/b $line_array[3]br\n"; echo"bBand/Folder:/b $line_array[4]br\n"; echo"bLink Name:/b $line_array[5]br\n"; echo"bLink URL:/b a href=\"$line_array[6]\" target=\"_blank\"$line_array[6]/abr\n"; echo "hr noshade"; } } echo "h3"; if ($found==0) { echo "No links found containing '$txtLinkname'!br"; }else{ echo "brFound: $found links containing $txtLinknamebr"; } echo "/h3h4"; echo "[ a href=\"post3.htm\"POST LINK/a | a href=\"index.php?action=view\"VIEW LINKS/a ]"; $found=0; echo "/h4"; ? And that is all the code I use. Where have I done wrong? You see, the problem is that I found only some links, but not all. And if I have a link called "Necrolust - Tribute to MayheM", it cannot find the "Necro" nor "necRO". And as you can see, I HAVE used uppercase methods to find portions and so forth. Any help is suggested!! - Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Searching arrayed file... Suggestions?
And that is all the code I use. Where have I done wrong? You see, the problem is that I found only some links, but not all. And if I have a link called "Necrolust - Tribute to MayheM", it cannot find the "Necro" nor "necRO". And as you can see, I HAVE used uppercase methods to find portions and so forth. Any help is suggested!! Seriously consider using MySQL or PosgreSQL, or some other form of DBMS. They will make your life so much easier. Jason Lotito www.NewbieNetwork.net -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
RE: [PHP] Searching arrayed file... Suggestions?
Have you evrer heard of in_array() ? could help though... :-) Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) [EMAIL PROTECTED] www.phpbeginner.com -Original Message- From: Richard [mailto:[EMAIL PROTECTED]] Sent: Saturday, April 21, 2001 9:50 PM To: [EMAIL PROTECTED] Subject: [PHP] Searching arrayed file... Suggestions? Greetings. I have made a try to write a search engine for a site I run. This search iterates through all links which are made up like so: "|BY|EMAIL|CATEGORY|FOLDER/BAND|LINKNAME|LINKURL|". Now, I use the code: if ($txtLinkname=="") return; $logfile="entries.txt"; $file_line = file($logfile); $total_lines = count($file_line); // Start printing the header of the table. The rest is completed, nested // course.. in the incrementation-loop. echo"table width=60% cellpadding=0 border=0 cellspacing=0 align=center"; echo"trtd width=100% valign=top align=left"; for($i=($total_lines-1); 0 = $i; $i--) { $line[] = $file_line[$i]; } echo "pbSearching for links containing $txtLinkname...br"; echo "hr noshade"; echo "/b"; for ($i=0; $i $total_lines; $i++){ $line_array = explode("|",$line[$i]); $swhere=strtolower($line_array[5]); $swhat=strtolower($txtLinkname); $pos = strpos ($swhere, $swhat); if ($pos0) { // not found }else if (($pos1) (!empty($pos))) { $found++; echo"bName:/b $line_array[1]br\n"; echo"bEmail:/b a href=\"mailto:$line_array[2]\"$line_array[2]/abr\n"; echo"bCategory:/b $line_array[3]br\n"; echo"bBand/Folder:/b $line_array[4]br\n"; echo"bLink Name:/b $line_array[5]br\n"; echo"bLink URL:/b a href=\"$line_array[6]\" target=\"_blank\"$line_array[6]/abr\n"; echo "hr noshade"; } } echo "h3"; if ($found==0) { echo "No links found containing '$txtLinkname'!br"; }else{ echo "brFound: $found links containing $txtLinknamebr"; } echo "/h3h4"; echo "[ a href=\"post3.htm\"POST LINK/a | a href=\"index.php?action=view\"VIEW LINKS/a ]"; $found=0; echo "/h4"; ? And that is all the code I use. Where have I done wrong? You see, the problem is that I found only some links, but not all. And if I have a link called "Necrolust - Tribute to MayheM", it cannot find the "Necro" nor "necRO". And as you can see, I HAVE used uppercase methods to find portions and so forth. Any help is suggested!! - Richard -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]