Hi Fransciso, Why did you use @? If you remove it, preg works correctly. If you want match only complete words, use $patern[$i] = "/\b".$words[$i]."\b/"; Regards from Brazil =D Jony dos Santos Kostetzer A2C Internet - R&D Em Ter 28 Mar 2006 19:47, Francisco - São Paulo - Brazil escreveu: > Suppose I have this: > > $words = array('piece','people'); > $profile_text = "I would like to meet people to help me to work in the > world piece project."; > > $marked = MarkWords($profile_text, $words); > > Should return the same sentece but with the 2 words replaced with the > <span> tag, am I wrong? > > function MarkWords($profile_text, $words){ > for($i=0; $i<count($words); $i++){ > $patern[$i] = "/@".$words[$i]."/"; > $replace[$i] = "<span > style='color:white'>".$words[$i]."</span>"; > } > // print_r($patern); > // print_r($replace); > > $pro = preg_replace($patern, $replace, $profile_text); > return $pro; > } -- PHP Data object relational mapping generator http://www.metastorage.net/ Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-objects/ <*> To unsubscribe from this group, send an email to: php-objects-unsubscribe@xxxxxxxxxxxxxxx <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/