How can I use str_replace in PHP without allowing it to re-replace the characters that have been used in the $replace_with in the following code?
<?php
$string='abcd';
$replace= array('a','c');
$replace_with = '[ac]';
$string=str_replace($replace,$replace_with,$string);
echo $string;
?>
The result would be:
"[a[ac]]b[ac]d"
How can I force my script to replace the 'a' in $string with '[ac]' once only without allowing it to replace the 'c' inside the newly inserted '[ac]'?