Location: PHPKode > projects > SvnDashboard > 1.1.3.140/phpLib/functions/array.funcs.php
<?php

//=============================================================================
//
// Description:
// 	Various functions for manipulating arrays
//
// Functions
//	arrayTrim( Array $array )
//	arrayClean( Array $array )
//
//=============================================================================

function arrayClean( $array, $trim = TRUE )
{
	//=============================================================================
	// Function: arrayClean
	// Author: Bob Jackman
	// Date: 2008-10-21
	// Description:	Function alias for arrayTrim -- Remove all array elements
	//				with empty strings or null values
	// Params:
	//	$array {array} Required:	Array on which to operate.
	//	$trim {bool} Optional:	Determines whether or not white space is trimmed
	//						from array elements before deciding whether to
	//						remove element from array.
	//
	// Returns: {array}	Resultant cleaned array
	//=============================================================================

	return arrayTrim( $array, $trim );
}

function arrayTrim( $array, $trim = TRUE )
{
	//=============================================================================
	// Function: arrayTrim
	// Author: Bob Jackman
	// Date: 2008-10-21
	// Description:	Remove all array elements with empty strings or null values
	// Params:
	//	$array {array} Required:	Array on which to operate
	//	$trim {bool} Optional:	Determines whether or not white space is trimmed
	//						from array elements before deciding whether to
	//						remove element from array.
	//
	// Returns: {array}	Resultant cleaned array
	//=============================================================================

	if (is_array($array)) // -- passed value is an array
	{
		// ====================  Find and Remove all Empty Array Elements
		$tempArray = array();
		foreach ($array as $index => $text) // -- remove empty elements
		{
			if ($trim)
			{
				$text = trim( $text ); // -- remove leading and trailing spaces
			}
			
			if ($text !== '' && $text !== null) // -- element value is not empty
			{
				$tempArray[$index] = $text;
			}
		}

		return $tempArray;
	}
	else // -- passed value is not an array
	{
		return $array;
	}
}

?>
Return current item: SvnDashboard