Question User Question User -4 years ago 106
PHP Question

how to add the custom format for price in php

I have price like this


Expected output


what i have tried is below

$num ='212500';
//echo money_format("The price is %i", $num);
$amount = '212500';
setlocale(LC_MONETARY, 'en_IN');
$amount = money_format('%!i', $amount);
echo $amount;

//echo $formattedNum = number_format($num, 2, ',', '');

Answer Source

As per your requirement you can do this .first divide the number by 100 and then change the format:

$amount = 212501;
echo number_format($amount/100, 2, '.', ',');//2,125.01
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download