John Craft
John Craft

Reputation: 63

PHP Price Convert?

I am currently grabbing data from steam, they are giving me the price however they are giving me it in this format "1999". That equals to $19.99. I am having problems with converting this to $19.99. I've looked at the money_format function but it isn't proving to be useful in this case. Any suggestions?

I haven't tried to code something up yet because I have no idea where to start. Thanks.

Upvotes: 0

Views: 64

Answers (1)

santamanno
santamanno

Reputation: 636

If you always get two decimals, you can:

$steamPrice = '1999';
$formattedPrice = '$' . round($steamPrice / 100, 2);

Should do the trick ;)

Upvotes: 1

Related Questions