Archive for the ‘PHP’ Category
Got Bored So Wrote A Function
Wednesday, September 26th, 2007I couldn’t sleep and was getting bored so I decided to write a function. I remember while reading a c++ book they showed you how to calculate the Fibonnaci number.
The Importance Of A Good IDE
Tuesday, September 25th, 2007Reading many forums, IRC channels and usenet’s I see many people bragging about how they can code without the use of an IDE. Although it is important for a programmer to have the ability to be able to program without such aids as an IDE to be more productive an IDE is a very important tool.
The End Is Nigh
Monday, September 24th, 2007Although it has been announced for some time a lot of people have as of yet to upgrade to PHP 5. The majority of people of course are at the complete mercy of their web host.
If your host has not upgraded yet you should of course take some preparation into ensuring that you will be prepared for when it does arrive. (more…)
Converting seconds to minutes and seconds
Sunday, August 26th, 2007Some time ago I was in IRC and someone asked how to convert x amount of seconds into seconds and minutes. This is somewhat of an easy task and here is a simple function which can do exactly that (please note no effort was made so it would work with anything more than an hour):-
function sec_to_min($sec='')
{
if (ctype_digit((string)$sec))
{
$seconds = $sec % 60;
$minutes = ($sec-$seconds)/60;
$min_sec = $minutes.':'.str_pad($seconds, 2, '0', STR_PAD_LEFT);
return $min_sec;
}
else
{
return '0:00';
}
}
Ways in which this could be enhanced:-
- Make it more aware of whether any minutes exist.
- Enhance it so that it can also work with hours, days etc.