Re: preg_replace_callback

From: Date: Thu, 18 Jul 2002 04:40:45 +0000
Subject: Re: preg_replace_callback
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108204@lists.php.net to get a copy of this message
In article <20020717190309.58922.qmail@pb1.pair.com>, rafael@aleph.com.br (Rafael Fernandes) wrote: > First, sorry for my elementary english... > I need a function made for PHP3 that works like preg_replace_callback... Before preg_replace_callback() was introduced, preg_replace() used to have another an "f" modifier which had similar functionality. I'm not sure whether that modifier was available back in PHP3, but here's the relevant quote about "f" from an old set of PCRE Syntax docs: > F > If this modifier is set, preg_replace() treats the replacement parameter as a > function name that should be called to provide the replacement string. The > function is passed an array of matched elements in the subject string. NOTE: > this modifier cannot be used along with /e modifier; and only preg_replace() > recognizes this modifier. If I recall correctly (which I may not), an example would look something like this: $output=preg_replace("/(\w+)/f","'***' . strtolower($1) . '***'",$input); -- CC

« previous php.general (#108204) next »