Str_replace is a simple problem. thank you... for example, $ a = & quot; 123a456a78a9a & quot; replace a with B, but only... if there is no good way... it can be determined that the number of digits before the last a is 12 digits ..... then, replace location a at location 13th. thank you ., P str_replace is a simple problem. thank you...
For example
$ A = "123a456a78a9a"
Replace a with B, but only the last...
If there is no good way to do this, you can determine that the number of digits before the last a is 12. then, you can only replace the 13th position;
Thank you.
------ Solution --------------------
PHP code
Echo strrev (preg_replace ('/a/', 'B', strrev ($ a), 1 ));
------ Solution --------------------
PHP code
Echo preg_replace ('/a [^ a] * $/', 'B', $ );
------ Solution --------------------
The above is wrong.
PHP code
Echo preg_replace ('/a ([^ a] *) $/', 'B $ 1', $ );