Article written

  • on 04.11.2009
  • at 03:39 PM
  • by arkin

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.

subscribe to comments RSS

There are no comments for this post

Please, feel free to post your own comment

* these are required fields

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