Nov4
I was loading alot of data from .csv files, some of the data was blank and i didnt want array key=>values for it, so i created an multi dimensional array cleansing tool.
function array_trim(&$a){
foreach( $a as $k => $v )
{
if ( is_array( $a[$k] ) ) array_trim( $a[$k] );
else $a[$k] = trim( $v );
if ( empty($a[$k]) ) unset( $a[$k] );
}
}
// Useage:
array_trim( $a );
Have fun.
Sep14
I wrote this snippet to convert ffmpeg’s information output time into seconds, i can then determine the 25, 50 and 75 percentages to create 3 different thumbnails of a movie (using ffmpeg also).
Heres the snippet:
function time2seconds($time='00:00:00'){
list($hr,$m,$s) = explode(':', $time);
return ( (int)$hr*3600 ) + ( (int)$m*60 ) + (int)$s;
}
Hope you find this as useful as I have.
Aug4
Recently, I was browsing the internet, as you do, and I came across a great little article that discussed the automatic versioning of stylesheets, javascript, flash and image files.
As i constantly have to hold shift when refreshing to get a full page refresh, I decided this method was genius and decided there were a few things needed to make it perfect.
continue reading »
Aug4
As a developer I often question myself when I have many occurrences of a function that could be replaced by something else. There are often many ways of achieving the same thing and only opinion standing in the way of a decision.
To solve this problem, I often benchmark certain peices of code multiple times to see which comes out the fastest. In this guide/tutorial I will teach you how to benchmark your own code.
continue reading »