Preg_replace there is a piece of PHP code replacing the PHP code. I want to change all characters between & lt; a & gt; and & lt;/a & gt; to uppercase PHPcodea = '& lt; a & gt; & lt ;? Php $ str = \ '0 \ '; if ($ str = \ '0 \') {echo $ str ;}? & Gt; & lt; preg_replace replacing PHP code
There is a piece of PHP code. I want to convert all the characters to uppercase.
PHP code
A ='
'; Echo preg_replace ("/(.*?) <\/A>/es ", '" ". strtoupper (" \ 1 ")." "', $ );
The output result is always incorrect. Some strings are always executed as PHP code (for example, the output result $ str is lost). how can I output the correct result? Or is there any other way to achieve this?
Thank you!
------ Solution --------------------
PHP code
$ A ='
'; Echo preg_replace_callback ("/(.*?) <\/A>/s ", 'foo', $ a); function foo ($ r) {return "". strtoupper ($ r [1]). "";}