Forum Moderators: coopster
<?php
$thefile = fopen("data/links.txt", "r") ;
$no=1 ;
$row=1 ;
while ($data = fgetcsv ($thefile, 250, ":")) {
$num = count($data);
$row++;
$keyword[$no]=$data[4] ; $no++;
$keyword[$no]=$data[5] ; $no++;
$keyword[$no]=$data[6] ; $no++;
}
for ($a=0; $a<$no; $a++) { for ($b=0; $b<$no; $b++) { if ($keyword[$b]!= $keyword[$a]) { $output = $output . "$keyword[$b]:"; } } }
echo $output ;
?>
Also why cant i do something like: $thefile="/data/links.txt" >> fopen($thefile, 250, ":")
If aynone can help, great
[webmasterworld.com...]
i'me wondering if ime missing a simple sollution to my comparison problem? :S
I have to say that crazy loop is hard to follow. Have you tried echo'ing the contents of what you are testing to see if it is just using/writing the wrong var?
That's usually the way I go about it to find mismatch probs. I am usually a victim of my own insanity and use the wrong var once in a while just to drive myself batty and always in the most complex little loop of the whole mess. ;)
open the file
read a row (element 4,5,6 are the keywords)
add each keyword to the massive keyword array
go through the keyword array and check for duplicates
add all unique keywords to output
spit out output
that right? with a little confirmation i may have an idea
[pre]$thefile = fopen("data/links.txt","r");
$no=0;
while ($data = fgetcsv ($thefile, 250, ":")) {
for($i=4;$i<=6;$i++) {
$keyword[$no]=$data[$i];
$no++;
}
}
$keyuniq = [url=http://ca.php.net/manual/en/function.array-unique.php]array_unique[/url]($keyword);
foreach($keyuniq as $newkey) $output .= "<br>" . $newkey;
echo $output;[/pre]
[webmasterworld.com...]
[webmasterworld.com...]
Sometimes when I have a little time I go through the functions in the manual to see if I can find something exciting or to just see how I could use some of the functions that I don't normally play with.
The user comments for most of the functions are full of tricks as well.