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