<offer id="10609" available="true">
<price>847</price>
<currencyId>RUB</currencyId>
<categoryId>787</categoryId>
</offer>
<offer id="10617" available="true">
<price>404</price>
<currencyId>RUB</currencyId>
<categoryId>787</categoryId>
</offer>
....
$str = '<offer id="10609" available="true">
<price>847</price>
<currencyId>RUB</currencyId>
<categoryId>787</categoryId>
</offer>
<offer id="10617" available="true">
<price>404</price>
<currencyId>RUB</currencyId>
<categoryId>787</categoryId>
</offer>';
$result = preg_replace_callback(
'/<price>(.*?)<\/price>/m',
function ($matches) {
return $matches[1] * 0.8;
},
$str
);
echo "The result of the substitution is " . $result;