PHP remove price and/or decimal and zeros Trim and substr methods

Trim method:

<?

trim(trim($num, '0'), '.');

?>

substr method:

<?

$num = number_format($num, 2);

if((substr($num, -1)==0) && (substr($num, -2)==0))
{
$num = number_format($num,0);
}
else
{
$num = $num;
}

?>

Comments are closed.