How do I change these codes using PHP code ...
I tried this but failed.
$str = str_replace(
array('A','/\'),
array('M','/\/\'),
array('N','/\/'),
array('V','\/'),
array('W','\/\/'),
$html);
What is the best practice for doing this?
You need to escape the backslashes. Also, you are not forming the parameters to str_replace correctly, they should be an array of strings and an array of replacements. This will do what you want:
$html = 'MAVEN WAR';
$str = str_replace(array('A', 'M', 'N', 'V', 'W'),
array('/\\','/\\/\\','/\\/','\\/','\\/\\/'),
$html);
echo $str;
Output:
/\/\/\\/E/\/ \/\//\R
A, M, N, V, W