errata

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

 



Now, if it's just for practice, then you need a little change in you code, since strtoupper('\\2') will give '\\2' (i.e. does nothing) and the letter will remain the same.

I meant, since *strtoupper('\\2')* is evaluated _before_ being included in the string (used as replacement), i.e...
  preg_replace('/(^)(.)(.*$)/', strtoupper('\\2') . '\\3', 'yikes!');
is evaluated as
  preg_replace('/(^)(.)(.*$)/', '\\2\\3', 'yikes!');
since *strtoupper('\\2')* => *'\\2'*, that's why I said it does nothing.

In the code sent, *strtoupper()* is passed as a (literal) string which, combined with the "e" modifier (at the end of the expression), gives the effect you were looking for (i.e. the "replacement string" is evaluated --as code-- before it actually replaces the string found)
--
Atentamente / Sincerely,
J. Rafael Salazar Magaña

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux