Hello,
How to convert percent value to decimal value in PHP to be used in a computation?
Example: 6.15% = .0615
Thanks!
$dec = $pct / 100; // if you actually have a % sign in $pct strip it out $pct = '15%'; $dec = str_replace('%', '', $pct) / 100;
function percentToDecimal($percent) { $percent = str_replace('%', '', $percent); return $percent / 100; }
echo floatval("6.15%") / 100;