Jump to content
MakeWebGames

Highlight text


03laceys

Recommended Posts

Ok so i am highlighting the text in explore using...

 

function highlightWords($string, $words)
{
   foreach ( $words as $word )
   {
       $string = str_ireplace($word, '<span class="highlight_word">'.$word.'</span>', $string);
   }
   /*** return the highlighted string ***/
   return $string;
}
$string = 'http://xvon.info/game/register.php?REF=$userid';
$words = array('http://xvon.info/game/register.php?REF=$userid');
$string =  highlightWords($string, $words);

 

Problem with using this is that it dosn't display the actuall userid it just display the code $userid

How am i able to highlight this particular text?

Thanks.

Link to comment
Share on other sites

function highlightWords($string, $words)
{
   foreach ( $words as $word )
   {
       $string = str_ireplace($word, '<span class="highlight_word">'.$word.'</span>', $string);
   }
   /*** return the highlighted string ***/
   return $string;
}
$string = 'http://xvon.info/game/register.php?REF='.$userid.'';
$words = array('http://xvon.info/game/register.php?REF='.$userid.'');
$string =  highlightWords($string, $words);
Link to comment
Share on other sites

It's not default with MCC, you say it as if MCC is a different language completely to PHP.

$string = ' blah ';

The reason you have to define the variable in this instance is down to the single quotes, single quotes will not look for a variable within a string whereas double quotes will, for example:

$string = "http://xvon.info/game/register.php?REF=$userid";

That would work fine.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...