Re: integer to string
| From: | Brian V Bonini | Date: | Thu, 15 May 2003 21:41:28 +0000 |
| Subject: | Re: integer to string | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-147823@lists.php.net to get a copy of this message | ||
On Thu, 2003-05-15 at 17:19, Adam Voigt wrote:
> $v = number_format($v,1);
I ended up doing sprintf("%.1f", $v)
Is that just as appropriate? Really was just the first thing I stumbled
across in the manual that seemed to do what I wanted.
>
> On Thu, 2003-05-15 at 10:27, Brian V Bonini wrote:
> > I have this:
> >
> > for($i = 1; $1 <= 2.1; $i += 0.1) {
> > $p_val[] = $i;
> > }
> >
> > foreach($p_val as $v) {
> > echo $v . "\n";
> > }
> >
> > which returns:
> >
> > 1
> > 1.1
> > 1.2
> > 1.3
> > 1.4
> > 1.5
> > 1.6
> > 1.7
> > 1.8
> > 1.9
> > 2
> >
> > how to I get it so that 1 & 2 are 1.0 & 2.0
> >
> > ??
> >
> > Thanks!
> --
> Adam Voigt (adam@cryptocomm.com)
> Linux/Unix Network Administrator
> The Cryptocomm Group