> 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]."/"; why "/@" ?? it must be: "/".$words[$i]."/" or "@".$words[$i]."@" and you, in this case dont need preg_replace, I suggest str_replace... or you want some like: $patern[$i] = "@(".$words[$i].")@i"; $replace[$i] = "<span style='color:white'>$1</span>"; -- José Miguel Santibáñez jms@xxxxxxxxx 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/