dgnzcn Posted December 3, 2009 Share Posted December 3, 2009 hi my highlight class is not hightlighting in mw search results.. class highlight { public $output_text; function __construct($text, $words) { $split_words = explode( " " , $words ); foreach ($split_words as $word) { $color = self::generate_colors(); $text = preg_replace("|($word)|Ui" , "<span style=\"background:".$color.";\"><b>$1</b></span>" , $text ); } $this->output_text = $text; } private function rgbhex($red, $green, $blue) { return sprintf('#%02X%02X%02X', $red, $green, $blue); } private function generate_colors() { $red = rand( rand(60,100) , rand(200,252) ); $green = rand( rand(60,100) , rand(200,252) ); $blue = rand( rand(60,100) , rand(200,252) ); $color = self::rgbhex( $red , $green , $blue ); return $color; } } <?php $aranan = '$aranan'; $renkver = new highlight ($row_Recordset1['aciklama'], $aranan); $ArananSonuc = $renkver ->output_text; echo $ArananSonuc ; ?> Quote Link to comment https://forums.phpfreaks.com/topic/183879-text-highlight/ Share on other sites More sharing options...
mattal999 Posted December 3, 2009 Share Posted December 3, 2009 My guess is that this line: $aranan = '$aranan'; Is being parsed, meaning that it will replace the $aranan inside the single quotes with the variable. The variable is not yet set, and therefore it is returned as ''. Try this instead: $aranan = "\$aranan"; EDIT: Never mind. Got it the wrong way round. What does the script return? Quote Link to comment https://forums.phpfreaks.com/topic/183879-text-highlight/#findComment-970687 Share on other sites More sharing options...
dgnzcn Posted December 3, 2009 Author Share Posted December 3, 2009 thanls for reply. search working but, searched words is not highlighting. Quote Link to comment https://forums.phpfreaks.com/topic/183879-text-highlight/#findComment-970699 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.