Re: preg_replace - What is wrong here?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> Thanks a lot for your message Jony dos Santos Kostetzer and José Miguel
> Santibáñez, actually that @ was my mistake, I got to solve it this way:
>
> But I am not happy because if I do this:
> $words = array('PEACE','people');
> $profile_text = "I would like to meet People to help me to work in the
> world Peace project.";
> $marked = MarkWords($profile_text, $words);
>
> This will return  (marked of course)
> "I would like to meet people to help me to work in the world PEACE
> project."
>
> But I would like to keep the orignal word and change just the color.


try my second option:

     $patern[$i] = "@(".$words[$i].")@i";
     $replace[$i] = '<span style=\'color:white\'>$1</span>';

(with a very little change)

I do:
Text   : queremos paz en el mundo. Paz a los hombres de buena voluntad
Pattern: /(paz)/i
Replace: <b>$1</b>
Result : queremos <b>paz</b> en el mundo. <b>Paz</b> a los hombres de buena
         voluntad

my 2 cents...

-- 
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/
 



[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Soap]     [Kernel Newbies]     [Yosemite]     [Yosemite Campsites]

  Powered by Linux