Okay. So in my search engine, for each array, there is a link to the page, where the page is located, and a description (a section from the body of the page) of the page.
By the way, I didn't just make a bunch of keywords and titles and links and descriptions. I have over 3000 files on my website. I wouldn't make keywords and titles and links and descriptions for every single one. It actually searches and sees if the keyword is in the body of any of the files on my website. If it has the keyword in it, it displays that page in the search results.
I have made a string called '$keyword' which is the word that the user searches for. Well actually, the keyword they insert into the form is called '$keywordin' and the actual word is called '$keyword' but that is only so I can tell the difference between the two. And it also makes sure there isn't two descriptions showing up. But I did say that $keywordin=$keyword; so they are the same thing.
That's the same thing with '$desc' and '$rdesc'. They are just different versions of the same thing. But they both have their own reason for being there. So just go along with me.
But anyway, in each description (which I have named $desc), I have told it that if it finds the inserted keyword anywhere in the description, to highlight the word. That works fine. But the problem is it capitalization-sensitive. So, I need help with this script I made to make it not capitalization-sensitive. Here is the script I am trying to use to do this:
//if the first letter of the inserted keyword isnt capitalized, make sure to
//highlight any $keywords in the $desc that do have their first letter capitalized
//along with the ones that dont
if(ucwords($keywordin) != true){
$uppercase = ucwords($keyword);
$replacek = "$uppercase";
$replacementk = "<b><font style='background-color: yellow'>$uppercase</font></b>";
$stringk = "$rdesc";
$rdesc = ereg_replace($replacek, $replacementk, $stringk);
}
if(ucwords($keywordin) == true) {
strtolower($keywordin);
$lowercase = strtolower($keyword);
$replacek = "$lowercase";
$replacementk = "<b><font style='background-color: yellow'>$lowercase</font></b>";
$stringk = "$desc";
$rdesc .= ereg_replace($replacek, $replacementk, $stringk);
}
The first part of the script works (the part that says: if(ucwords($keywordin) != true){ blah blah blah). If they insert a keyword that has a lowercase first letter, then it will highlight the keywords that have capitalized first letters along with those that have lowercase first letters..
But if they insert a keyword with a capitalized first letter, it only highlights the keywords with capitalized first letters. It doesn't capitalize the keywords with lowercase first letters. But the second part of the script (if(ucwords($keywordin) == true) { blah blah blah) is supposed to make sure that it capitalizes all of them.
Can someone please help me?
By the way, I didn't just make a bunch of keywords and titles and links and descriptions. I have over 3000 files on my website. I wouldn't make keywords and titles and links and descriptions for every single one. It actually searches and sees if the keyword is in the body of any of the files on my website. If it has the keyword in it, it displays that page in the search results.
I have made a string called '$keyword' which is the word that the user searches for. Well actually, the keyword they insert into the form is called '$keywordin' and the actual word is called '$keyword' but that is only so I can tell the difference between the two. And it also makes sure there isn't two descriptions showing up. But I did say that $keywordin=$keyword; so they are the same thing.
That's the same thing with '$desc' and '$rdesc'. They are just different versions of the same thing. But they both have their own reason for being there. So just go along with me.
But anyway, in each description (which I have named $desc), I have told it that if it finds the inserted keyword anywhere in the description, to highlight the word. That works fine. But the problem is it capitalization-sensitive. So, I need help with this script I made to make it not capitalization-sensitive. Here is the script I am trying to use to do this:
//if the first letter of the inserted keyword isnt capitalized, make sure to
//highlight any $keywords in the $desc that do have their first letter capitalized
//along with the ones that dont
if(ucwords($keywordin) != true){
$uppercase = ucwords($keyword);
$replacek = "$uppercase";
$replacementk = "<b><font style='background-color: yellow'>$uppercase</font></b>";
$stringk = "$rdesc";
$rdesc = ereg_replace($replacek, $replacementk, $stringk);
}
if(ucwords($keywordin) == true) {
strtolower($keywordin);
$lowercase = strtolower($keyword);
$replacek = "$lowercase";
$replacementk = "<b><font style='background-color: yellow'>$lowercase</font></b>";
$stringk = "$desc";
$rdesc .= ereg_replace($replacek, $replacementk, $stringk);
}
The first part of the script works (the part that says: if(ucwords($keywordin) != true){ blah blah blah). If they insert a keyword that has a lowercase first letter, then it will highlight the keywords that have capitalized first letters along with those that have lowercase first letters..
But if they insert a keyword with a capitalized first letter, it only highlights the keywords with capitalized first letters. It doesn't capitalize the keywords with lowercase first letters. But the second part of the script (if(ucwords($keywordin) == true) { blah blah blah) is supposed to make sure that it capitalizes all of them.
Can someone please help me?