mzhou88 Posted March 19, 2007 Share Posted March 19, 2007 preg_replace("/{$match}{$_Conf['FileManip']['Splitter']}(\d+)/i","{$match}{$_Conf['FileManip']['Splitter']}".$1+1,$Read) Currently I am trying to figureout how to add 1 to the (\d+). but when i do whatever i did just now, it gives me this error: Parse error: syntax error, unexpected T_LNUMBER, expecting T_VARIABLE or '$' in D:\xampplite\htdocs\includes\bbcode.php on line 134 thx =p Link to comment https://forums.phpfreaks.com/topic/43351-preg_replace-1-to-matched-number/ Share on other sites More sharing options...
effigy Posted March 19, 2007 Share Posted March 19, 2007 I think the $1 has to be in quotes, which requires the /e modifier to do the addition: <pre> <?php $string = '1'; echo preg_replace('/(\d+)/e', "$1+1", $string); ?> </pre> Link to comment https://forums.phpfreaks.com/topic/43351-preg_replace-1-to-matched-number/#findComment-210568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.