My trouble is to multiply numbers in string that contains various characters.
For example,
Input:
$k = 2;
$input = '<div style="padding:10px 15px; font-size:1em ;height:2%;"></div>';
Output:
<div style="padding:20px 30px; font-size:2em ;height:4%;"></div>
Edit
$k can be any whole number (0-9). All numbers from $input string are multiplied by $k.
I’d use
preg_replace_callback:The above only replace numbers followed by
px,emor%.You could also provide
$kto the lambda function yourself, for more flexibility: