im making a search feature and its all working fine at the moment, the only problem i am having, is when my search comes through i have the particular search word highlighted in orange on the results, thats fine, BUT i was hoping it would preserve the case.
for example when i search for vray it changes all of them to vray instead of VRay. so id just like it too preserve the case.
at first i used str_replace, but it is case sensitive so it didnt show all the relevant searches highlighted in orange, and now im using eregi_replace so its catching the ones with uppercase and lowercase letters. i know its possible to just convert the first letter to uppercase, but i used VRay as an example above as it has 2 upper case letters to start.
would some regex do the trick? if so how would you go about doing that?
heres my relevant code:
while($row = mysql_fetch_object($result_portfolio))
{
$string_p_1 = "<table style=\"width: 100%; text-align: center; border-top: 1px dashed #EFEFEF;\"><tr><td width=\"100px\" height=\"100px\" style=\"text-align: left;\"><a href=\"$row->image_url\" target=\"_BLANK\"><img src=\"$row->thumb_url\" border=\"2\" height=\"90px\" width=\"90px\" alt=\"$row->title\" /></a></td>";
$string_p_2 = "<td style=\"text-align: left;\"><b>Title:</b> $row->title<br /><b>Description:</b> $row->description<br /><b>Category:</b> $row->category<br /><i>Submitted On $row->date</i></td></tr>
</table>
<br />";
$str_string_p = eregi_replace($search_item, '<font color=orange>'.$search_item.'</font>', $string_p_2);
echo "$string_p_1 $str_string_p";
}
}
else{
echo "<h1>No Results from Porfolio</h1>";
}
sorry about the lack of indenting, it seems to have dissappeared in here... *note too self: use spaces not tabs*
if you want to search for VRay to see what i mean, look in my portfolio @ the portfolio page and notice how some entries in the 3D section that have vray in them are spelt as VRay (example is 3/4 down named 'The Arches'), then use the search function and search vray and notice that they are all changed to vray.
any help most appreciated
Edited by Stu, 25 January 2006 - 07:05 AM.
