<?php $vars = [ "profitPercent", "productPrice", "weight", "quantityInCart", "lineTotal", "cartTotal", "billingUnits", "test_111", "test_213", "test_prod_input_15", "test_prod_input_16" ]; $chars = ["\d", "(", ".", "*", "+", "/"]; $algo = 'this is a string with a {productPrice} variable and some 827/100 math in it'; $pattern = "~(?:{" . implode('}|{', $vars) . '}|[' . implode('', $chars) . ']+)~'; preg_match_all($pattern, $algo, $matches); echo implode('', $matches[0]);
You have javascript disabled. You will not be able to edit any code.