Jump to content

Help with number_format


kawaii1001

Recommended Posts

I am getting the following error message with the below code:

Warning: number_format() expects parameter 1 to be double, object given in ...

<?php
        $price=$preownedinfo->Price;    
        $formatted_price = number_format($price, 2);
    echo $formatted_price;
?>

Can you tell me what might be the issue.  Thanks.

Link to comment
https://forums.phpfreaks.com/topic/282255-help-with-number_format/
Share on other sites

Edit:  Just saw it was an object, I was thinking string: 

var_dump($price);

Depends on what echo $price; shows, but most likely:

$price = (float)$preownedinfo->Price;
//or
$formatted_price = number_format((float)$price

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.