The preg_replace function of PHP 8.1 shows a strange behavior when combined with double lower quotation marks.
Here is a short example, that shows the issue:
<?php
#this does not work
$bearbeitet = "Hallo „Pivot text";
$bearbeitet = preg_replace("/[W][Pp][Ii][Vv][Oo][Tt][W]/", " <span class='abbrv' title='Performance Programm'>PIVOT</span> ", $bearbeitet);
echo $bearbeitet;
?>
If you run this code it will put a strange symbol infront of the replaced text that breaks my skript. If you have any other symbol instead of the double lower quotation marks it works fine:
<?php
#this works
$bearbeitet = "Hallo (Pivot text";
$bearbeitet = preg_replace("/[W][Pp][Ii][Vv][Oo][Tt][W]/", " <span class='abbrv' title='Performance Programm'>PIVOT</span> ", $bearbeitet);
echo $bearbeitet;
?>
Am I missing something or is that a Bug in PHP?
New contributor
Robert B. is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.