K. Doe K. Doe - 1 year ago 72
PHP Question

Converting number-formatted variable back to original format - PHP

I used number_format in a number. I want to know how to convert number-formatted variable in php back to its original format

I first used number_format. And I want to echo back its original format removing the number format.

$number = 500000
echo number_format($number, 2);

$number = 500000;
$formattedNumber = number_format($number, 2);
$getBackOriginl = explode('.',$formattedNumber);
echo str_replace(',','',$getBackOriginl[0]);