» Quick Links
You can make money on these forums
We Share profits with you
Google
Google Adsense
Google Adwords
YPN
Yahoo
MSN Search
Web Directories
Web Hosting
Web Hosting Offers
Hosting News
Suggestions
Link Building
Domain Names
PHP Forums
MySQL Forums
» More Links
OSP News
Reseller Hosting
Shared Hosting
Dedicated Servers
Google Adsense
Search Engine Marketing
Link Development
Affiliate Marketing


» Advertising
Multiple DC PR Check

Free SEO Tools


Go Back   Webmaster Forums > Website Developement / Programming > PHP Programming and Tips

PHP Programming and Tips Discuss about PHP programming and Share Tips. Ask questions about Scripting and Errors.

Reply
 
Thread Tools Display Modes
  #1  
Old 08-09-2006, 11:54 AM
strings strings is offline
Junior Member
 
Join Date: Aug 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
strings is on a distinguished road
Cool matching strings

Hi

I am trying to figure out if this is at all possible.

When a user searches for a certain string, it replaces the string with bold text, and I accomplished that by doing this:

PHP Code:
//$query = 'DEV'
str_replace($query, '<b>'.$query.'</b>', $results);
//return <b>DEV</b>
//doesn't return <b>Dev</b>

However, if they search for DEV, it will just bold the results that are in all caps, and I am trying for it to return anything that matches DEV, lower or upper case.

What gives??
Bye -- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Revenue Sharing Ads ( ?):
  #2  
Old 08-09-2006, 11:56 AM
valentino valentino is offline
OSP Starters
 
Join Date: Aug 2006
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Rep Power: 0
valentino is on a distinguished road
Default

This function is pulled straight off the php.net site under the str_replace function, written by: dbergeron [at] clincab [dot] com

I used it a while go on a site for highlighting text, should be fine.

Code

<?php
function highlight($x,$var) {//$x is the string, $var is the text to be highlighted
if ($var != "") {
$xtemp = "";
$i=0;
while($i<strlen($x)){
if((($i + strlen($var)) <= strlen($x)) && (strcasecmp($var, substr($x, $i, strlen($var))) == 0)) {
//this version bolds the text. you can replace the html tags with whatever you like.
$xtemp .= "<b>" . substr($x, $i , strlen($var)) . "</b>";
$i += strlen($var);
}
else {
$xtemp .= $x{$i};
$i++;
-- This message may have been cut off and the rest will only be shown to members. To become a member, click here --
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
best fit matching??? Jamarien MySQL Forums 1 08-21-2006 04:29 AM
Welcome to strings on OutSourcingPlans... osp Introductions 0 08-09-2006 11:53 AM
matching a search term? Mohammad MySQL Forums 1 08-08-2006 07:15 AM
pattern matching problem pifer PHP Programming and Tips 1 08-03-2006 04:42 PM
SQL Server 2000 + inserting quoted strings charles MySQL Forums 1 07-30-2006 10:35 AM


All times are GMT. The time now is 02:53 PM.