/e modifier

From: Date: Tue, 22 Jun 1999 14:59:10 +0000
Subject: /e modifier
Groups: php.version4 
Request: Send a blank email to php-version4+get-1651@lists.php.net to get a copy of this message
I just added a new /e modifier for preg_replace which lets you do dynamic replacement parameter evaluation, and thus, some wonderful things. Example: $text = "PHP is a scripting language. it works on everything. really."; echo preg_replace("/([.?!]\s+)(\w)/e", "'\\1'.strtoupper('\\2')", $text); This will capitalize the first letter of the sentence. As you can see, the possibilities abound. P.S. Since error printing function is not NULL safe currently, you will get a core dump if the eval string is not syntactically correct. -Andrey * Anything will fit if you push hard enough *

« previous php.version4 (#1651) next »