RE: [PHP] how to convert simplexml oblect to float
| From: | George Pitcher | Date: | Mon, 20 Nov 2006 15:12:41 +0000 |
| Subject: | RE: [PHP] how to convert simplexml oblect to float | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-244879@lists.php.net to get a copy of this message | ||
Edward,
Thanks - did the trick.
Cheers
George
> -----Original Message-----
> From: Edward Kay [mailto:edward@labhut.com]
> Sent: 20 November 2006 9:29 am
> To: George Pitcher
> Cc: php-general@lists.php.net
> Subject: RE: [PHP] how to convert simplexml oblect to float
>
>
> You'll need to convert from a string to an int/float if you want to do any
> arithmetic on your value.
>
> (float) $fee
>
> should do the trick. Yes, you'll 'loose' the decimal price
> padding but this
> can simply be restored by using sprintf when you need to output
> the price as
> a string.
>
> Edward
>
>
> > Hi all,
> >
> > Does anyone know a way to convert a simplexml object to a float
> variable?
> >
> > I have an onbect: $fee, which is a decimal price. I need to add
> > something to
> > this price, but I loose the decimal part if I do. I've tried using
> > settype($fee, "float") but that doesn't work.
> >
> > All the simplexml examples in the manual concern strings, not numbers.
> >
> > Any suggestions?
> >
> > MTIA
> >
> > George in Oxford
> >
> > --
> > PHP General Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
> >
> >
>
>