kawaii1001 Posted September 18, 2013 Share Posted September 18, 2013 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. Quote Link to comment Share on other sites More sharing options...
AbraCadaver Posted September 18, 2013 Share Posted September 18, 2013 (edited) 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 Edited September 18, 2013 by AbraCadaver Quote Link to comment Share on other sites More sharing options...
requinix Posted September 18, 2013 Share Posted September 18, 2013 (edited) If you're getting this from SimpleXML, pretty much everything it returns is an object. Use typecasting like Abra showed. Edited September 18, 2013 by requinix Quote Link to comment Share on other sites More sharing options...
Solution kawaii1001 Posted September 18, 2013 Author Solution Share Posted September 18, 2013 Excellent. Worked. Thanks! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.