To replace a backslash you have to escape it with another backslash. So in your example to replace \\
you have to escape each of them with backslash, so you can try this
$replaced = str_replace('\\\\', '\\', $str1);
solved How can I replace a blackslash character? [duplicate]