Tag PHP

PHP Function: array_trim 0

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.

Convert time (hr:min:secs) into seconds 3

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.

Automatically Version your Javascript & Stylesheets 1

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 »

Benchmark your PHP code 0

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 »

arkinEx Codex is powered by WordPress and FREEmium Theme.
developed by Dariusz Siedlecki and brought to you by FreebiesDock.com