Return to Snippet

Revision: 20394
at November 14, 2009 14:25 by Knarf


Initial Code
/*  - function trim_array() -
	 *
	 * A function for quicly triming all variables in an array
	 *
	 */
	
	function trim_array($value) 
	{ 
		foreach($value as $name => $item) {				// Walk's trou the array
			if(is_array($item)) {						// If the variable is an array:
				$tmp[$name] = trim_array($item);		//   - We need to trim that one first
			} else {									// Else:
				$tmp[$name] = trim($item);				//   - Trims the variable
			}
		}
		return $tmp; 									// Return the trimed versjon of the array
	}

Initial URL

                                

Initial Description
A function i made for running trim on all elements in an array

Initial Title
php trim alle elements in an array

Initial Tags
php, array

Initial Language
PHP