errata

From: Date: Wed, 14 Jun 2006 00:33:34 +0000
Subject: errata
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-237942@lists.php.net to get a copy of this message
    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

« previous php.general (#237942) next »