Jan 21, 2009 #1 Brianfree Programmer Joined Feb 6, 2008 Messages 220 Location GB Hi, i have some php values like... 7.5000 11.5000 25 How can i display them like... 7.50 11.50 25.00 Many thanks, BF
Hi, i have some php values like... 7.5000 11.5000 25 How can i display them like... 7.50 11.50 25.00 Many thanks, BF
Jan 21, 2009 #2 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi Code: [blue]master #[/blue] for n in 7.5000 11.5000 25; do [blue]>[/blue] printf '%.2f\n' "$n" [blue]>[/blue] done 7.50 11.50 25.00 Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Code: [blue]master #[/blue] for n in 7.5000 11.5000 25; do [blue]>[/blue] printf '%.2f\n' "$n" [blue]>[/blue] done 7.50 11.50 25.00 Feherke. http://rootshell.be/~feherke/
Jan 21, 2009 Thread starter #3 Brianfree Programmer Joined Feb 6, 2008 Messages 220 Location GB Hi thanks for replying, is there a way to do this in a function like... format(value,'.00') or something? The values are from a recordset.. Many thanks, BF Upvote 0 Downvote
Hi thanks for replying, is there a way to do this in a function like... format(value,'.00') or something? The values are from a recordset.. Many thanks, BF
Jan 21, 2009 #4 feherke Programmer Joined Aug 5, 2002 Messages 9,541 Location RO Hi Oops. Sorry. I have no idea why I had the feeling the you asked in the Unix scripting forum. However the [tt]printf()[/tt] function of C is implemented/replicated in many languages. Including PHP. I think you probably want its variant, the [tt]sprintf()[/tt] function. PHP: $formatted = sprintf( '%.2f', $value ); Feherke. http://rootshell.be/~feherke/ Upvote 0 Downvote
Hi Oops. Sorry. I have no idea why I had the feeling the you asked in the Unix scripting forum. However the [tt]printf()[/tt] function of C is implemented/replicated in many languages. Including PHP. I think you probably want its variant, the [tt]sprintf()[/tt] function. PHP: $formatted = sprintf( '%.2f', $value ); Feherke. http://rootshell.be/~feherke/