I want to perform value replacement based on matched value. The replacement expression has calculation based on matched value.
<?php
$re = '/<w:d([^\[]+)\/>/m';
$str = '<w:d2/>';
//$subst = "<w:ind w:left='.eval(\"return \".\"720*$1;\").' w:right=\"\"/>";
$subst = "<w:ind w:left='".eval("return 720*$1;")."' w:right=\"\"/>";
$result = preg_replace($re, $subst, $str);
echo "The result of the substitution is ".$result;
?>
I want to multiply 720 with matched value an return it in string.
I got error :
syntax error, unexpected '1' (T_LNUMBER), expecting variable (T_VARIABLE) or '{' or '$' : eval()'d code on line 1