Le 04/05/2013 14:39, Laruence a écrit : > with this patch, preg_replace_callback will call user callback with two > arguments, the first one is the same, the second is the regex key if the > regex is an array or NULL if the regex is a string.
Here is another example from a real case (Horde_Date) return preg_replace( array('/%b/e', '/%B/e', '/%C/e', '/%([-#]?)d/e', '/%D/e', '/%e/e', '/%([-#]?)H/e', '/%([-#]?)I/e', '/%([-#]?)m/e', '/%([-#]?)M/e', '/%n/', '/%p/e', '/%R/e', '/%([-#]?)S/e', '/%t/', '/%T/e', '/%x/e', '/%X/e', '/%y/e', '/%Y/', '/%%/'), array('$this->strftime(Horde_Nls::getLangInfo(constant(\'ABMON_\' . (int)$this->_month)))', '$this->strftime(Horde_Nls::getLangInfo(constant(\'MON_\' . (int)$this->_month)))', '(int)($this->_year / 100)', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_mday)', '$this->strftime(\'%m/%d/%y\')', 'sprintf(\'%2d\', $this->_mday)', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_hour)', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_hour == 0 ? 12 : ($this->_hour > 12 ? $this->_hour - 12 : $this->_hour))', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_month)', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_min)', "\n", '$this->strftime(Horde_Nls::getLangInfo($this->_hour < 12 ? AM_STR : PM_STR))', '$this->strftime(\'%H:%M\')', 'sprintf(\'%\' . (\'$1\' ? \'\' : \'02\') . \'d\', $this->_sec)', "\t", '$this->strftime(\'%H:%M:%S\')', '$this->strftime(Horde_Nls::getLangInfo(D_FMT))', '$this->strftime(Horde_Nls::getLangInfo(T_FMT))', 'substr(sprintf(\'%04d\', $this->_year), -2)', (int)$this->_year, '%'), $format); } Note, while I agree for this feature, must application / framework will have to be fixed, but also kept compatible with 5.3, 5.4, 5.5. Remi. -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php