Programming challenge (in php)

Mr Ritter plug at candlefire.org
Mon Oct 1 12:23:43 MDT 2007


Kenneth Burgener wrote:
> Just for kicks and giggles here is my attempt.  Not quite as elegant as
> the others, but does the job.  I included the one liner version below
> just for fun.

If speed is of any concern there are a few immediate things you can do 
to optimize.

1) quotes -- use single unless the string truly needs evaluation.  This 
is an extra step for php that is largely not needed. Especially inside 
loops.
ex: echo time2sec('1:36') . "\n";
ex: if( $char == ':' ) {

2) echo -- use commas not periods, when there is no need to concatenate.
ex: echo time2sec('1:36'), "\n";


HTH,


--
Ritter



More information about the PLUG mailing list