Current location: Hot Scripts Forums » Programming Languages » PHP » Help with using preg_replace

Help with using preg_replace

 
Prev Previous Post   Next Post Next
  #1 (permalink)  
Old 06-23-09, 04:57 PM
myklt myklt is offline
Newbie Coder
 
Join Date: Feb 2009
Location: UK
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Help with using preg_replace

I am having problems with finishing a function I have made which uses PHP's preg_replace.

The function runs through text within a forum I am designing to highlight target words to the user based on their interests etc I am hoping to allow a customizable tool-tip to pop-up over the highlighted areas to give the user extra information/ links etc.

The function is highlighting the words 100% and my tooltip is displaying the way I want it atm BUT the problem I am having is getting the PHP variable $definition to output its content instead of "$definition".

The problem seems to be the method I am trying to output a variable within a String. I have exausted every way I know of doing this and would like help. I have tried using <?php echo "$definition"?>, ".$definition.", print $definition, echo $definition....

Does anyone know any way or method to get the output of $definition to populate the tooltips?

PHP Code:
function getTargetWords($fContent){
....
.... 
....

/***Definition***/
       
$definition "Definition text for inside the tooltip";

/***!!!!!!!!To be fixed to output tooltip definition not "$definition" !!!!!!!!!***/        
       
$replace '<a href="#"><span class="highlight_word">\1<span class="tooltip">$definition</span></span></a>';
                
 
/*** highlight the words ***/
         
$fContent preg_replace("/\b($word)\b/i"$replace$fContent);
....
....
....

any help will be appreciated, thanks
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Share on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump


All times are GMT -5. The time now is 10:06 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.