如何在PHP中将百分比值转换为十进制值以用于计算?

示例:6.15%= .0615

最佳答案

$dec = $pct / 100.00;

// if you actually have a % sign in $pct strip it out
$pct = '15%';
$dec = str_replace('%', '', $pct) / 100.00;

09-13 10:32