On Sun, 23 Nov 2003, David Otton wrote:
> >How about something like this:
> >$hstart = 7; $hend = 19; $interval = 15;
> >for($h=$hstart; $h < $hend; $h++) {
> >  for($m=0; $m < 60; $m += $interval) {
> >    echo sprintf("%d:%02d",$h,$m); } }
>
> Couple of suggestions on top:
> replace "echo sprintf" with a simple "printf".

Yes.. I thought it would be more illustrative to use sprintf, as printf
alone might look more foreign and is less versatile in this case
(especially were it made into a function)...

> If I was going to bother to use a function here, I'd work with unix
> timestamps and strftime() (http://www.php.net/strftime) so my function
> would return values in pretty much any format, and at 1 second res...

Well, sure.. but that would be overkill for a simple select list
of the type described.  As for coding it as a function, I was only trying
to suggest this is the type of thing that makes a good function--not that
what I put down there would make the ultimate function of this type.

I thought taking it further and making it into a function myself
1) might seem like I was trying to be showy and 2) feared the example 
would start losing it's demonstrative value with extra functionality.

-- 
Kelly Hallman
// Ultrafancy

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to