PHP Function: array_trim
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( [...]
Convert time (hr:min:secs) into seconds
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 [...]
Automatically Version your Javascript & Stylesheets
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 [...]
Benchmark your PHP code
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 [...]
