Forum Moderators: coopster
The thing is ... I have a paragraph or two of text leaded in a string.
I also have a list of sub directories.
Now I want to find out which sub directory name is most suitable to the content. After reading a bit i think strpos is the best way to go.
this is how far i got :-
$scanthis = '.';
$scanlisting = scandir($scanthis);
$dirlisting = array();
foreach($scanlisting as $key => $value){
if (is_dir("$scanthis/$value") == true && $value!= '.' && $value!= '..'){
$dirlisting[] = $value;
}
} print('<ul>');
foreach($dirlisting as $key => $value){
$pos = strrpos($content, $value);
if ($pos === false) { // note: three equal signs
// not found...
} else {
print('<li><a href="' . $scanthis . '/' . $value . '">' . $value . "</a></br></li>");
}
}
print('</ul>');
So far it is diving me only an alphabetical list.
I would like to list it based on the following criteria.
1) The number of times the phrase occurs.
2) The first occurrence.
if more than 1 phrase has a tie in the first criteria, then look for the second.
How do i go about it?
Im sure it would be a piece of cake for the php gurus...
Thanks in advance.