I have a problem with recreation function written in Javascript, to make it work in php. I think that I am really close, but don't understand php syntax that well. So I have something like that in JS:
function convertStr(str, id) {
const regexExpression = new RegExp('PR|PD|DD|DPD|DP_AVG', 'g');
return str.replace(regexExpression, match => match + id);
}
So I try to do the same in php and I have this:
$reg = "/PR|PD|DD|DPD|DP_AVG\g/";
$result = preg_replace($reg, ??, $str)
So I don't know what to put in "??", because as I understand in JS it is my match arrow function match => match + id, but I can't perform it in PHP.
Can anyone help?
Best,
Piotr
\g, replace with'$0' . $id