[LUNI] How do you in php???

Joel F. Hacker qa6240 at email.mot.com
Sat Apr 24 16:45:36 CDT 2004


Hi,

I am busy porting some cgi scripts to php
to learn php.  I thought that I would ask two
of the trickier questions that I had in perl and
see if any guru's knew how to do it in php/mysql.

The first one is a rounding routine...How do you
round to two decimal numbers in php??? 
I perl, I did it like this:

$input = sprintf("%.2f", $input);


Second question is, how do you sort on the date
in a when I have three separate columns for year,
month, and day???

In perl, I did it like this:

my @in = @_;
my @sorted = sort { ${$a}[1] cmp ${$b}[1] or ${$a}[2] cmp ${$b}[2] or 
${$a}[3] cmp ${$b}[3] } @in;

Thanks in advance for all your help!

Joel




More information about the luni mailing list