- Code: Select all
<?php
$string = " I'm a string ";
$pattern = "/&#(\d\d);/";
$replacement = chr("$1");
echo preg_replace($pattern, $replacement, $string);
?>
I think that in the replacement slot is not possible to use chr("$1") even if:
1) with $replacement = chr(39) preg_replace correctly returns the apostrophe
2) with $replacement = $1 preg_replace correctly returns "39"
how can i solve it ?
Thanks for you help

