RE: [PHP] Searching arrayed file... Suggestions?

From: Date: Sat, 21 Apr 2001 13:14:51 +0000
Subject: RE: [PHP] Searching arrayed file... Suggestions?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-49666@lists.php.net to get a copy of this message
Have you evrer heard of in_array() ? could help though... :-) Sincerely, Maxim Maletsky Founder, Chief Developer PHPBeginner.com (Where PHP Begins) maxim@phpbeginner.com www.phpbeginner.com -----Original Message----- From: Richard [mailto:oblivion@lunamorena.net] Sent: Saturday, April 21, 2001 9:50 PM To: php-general@lists.php.net 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"<tr><td width=100% valign=top align=left>"; for($i=($total_lines-1); 0 <= $i; $i--) { $line[] = $file_line[$i]; } echo "<p><b>Searching 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 ($pos<0) { // not found }else if (($pos>1) && (!empty($pos))) { $found++; echo"<b>Name:</b> $line_array[1]<br>\n"; echo"<b>Email:</b> <a href=\"mailto:$line_array[2]\">$line_array[2]</a><br>\n"; echo"<b>Category:</b> $line_array[3]<br>\n"; echo"<b>Band/Folder:</b> $line_array[4]<br>\n"; echo"<b>Link Name:</b> $line_array[5]<br>\n"; echo"<b>Link URL:</b> <a href=\"$line_array[6]\" target=\"_blank\">$line_array[6]</a><br>\n"; echo "<hr noshade>"; } } echo "<h3>"; if ($found==0) { echo "No links found containing '$txtLinkname'!<br>"; }else{ echo "<br>Found: $found links containing $txtLinkname<br>"; } echo "</h3><h4>"; 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: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#49666) next »