- strpos: documentation ( source)
- preg_replace: documentation ( source)
<?php
function dePercent($value)
{
$number = preg_replace("/[^0-9.]/", "", $value);
if (strpos($value,'%') !== FALSE) {
return intval($number)*.01;
}
return $number;
}
dePercent("%5");