Preg_replace the replacement value has a subexpression value plus a numerical value. this post is finally edited by panlvfei from 2014-04-0215:3. The following is a simple replacement: $ ih100; $ aaa123b; $ aapreg_replace (^ () 123 (B) $ I, $1. $ ih. $2, $ aa); the replacement value of pri preg_replace has a subexpression value plus a value.
This post was last edited by panlvfei at 15:31:02
The following is a simple replacement:
$ Ih = 100;
$ Aa = 'a123b ';
$ Aa = preg_replace ('/^ (a) 123 (B) $/I', '$ 1'. $ ih.' $ 2', $ aa );
Print_r ($ aa );
The result is incorrect. if $ ih is changed to a letter, the first and $1 digits will be lost. Adding a letter at $1 is normal. isn't it my computer problem?
------ Solution --------------------
$ Aa = preg_replace ('/^ (a) 123 (B) $/ie',' "$1". $ ih. "$2" ', $ aa );
------ Solution --------------------
$ Ih = 500;
$ Aa = 'a123b ';
$ Aa = preg_replace ('/^ (a) 123 (B) $/I', '$ {1 }'. $ ih. '$ {2}', $ aa );
Print_r ($ aa );