<?php
$str = htmlspecialchars('<nav><a>something</a></nav>');
$pattern = htmlspecialchars('/<nav><a>something</a></nav>/i');
echo htmlspecialchars(preg_replace($pattern, '<nav> <a href="hi">click</a>
</nav>', $str));
?>
I need PHP to echo like this:
<nav> <a href="hi">click</a> </nav>
But it's showing this error:
Warning: preg_replace() expects parameter 4 to be int, string given in /opt/lampp/htdocs/Workaera/Sample.php on line 19
$pattern. Trystripos()instead of preg_replace.