PHP Code
 public function Arr_Resize($Arr, $ArrCount, $ReplicateLastValue = true, $FillValue = null) {
		/*
		Purpose
			Used to resize an array to a specified length.
		Parameters
			Arr (Array) = The array we're going to resize.
			ArrCount (Array) = The returned array will contain this number of elements.
				If negative, defaults to zero (0).
			ReplicateLastValue (Optional Boolean) = Determines what value is assinged to new elements in an array.
				If true, new elements are simply taken from the last element.
				If false, new elements receive the value specified in FillValue.
				If ReplicateLastValue is true and an empty array must be extended (there are no values to replicate),
					then the value of FillValue is used to fill new elements.
				Default: true
			FillValue (Optional Mixed) = If elements are added, if ReplicateLastValue is true,
				then this is the value for all new elements.
				Default: null
		Return (Array)
			Returns Arr resized so it has the specified number of elements (ArrCount).
			Keys are not touched. Elements added by this function contain natural numeric keys.
		Version History
			1.0 11/21/2008 Tested by Russ Tanner on PHP 5
		*/

		// Filter: ArrCount is negative. Default it to zero (0).
		if ($ArrCount < 0) $ArrCount = 0;
		
		// The specified size is smaller than the source array, remove elements from the source array and return the results.
		if ($ArrCount < count($Arr)) return array_slice($Arr, 0, $ArrCount);
				
		// We're about to use FillValue. Make sure it has the right value.
		if ($ReplicateLastValue) if (count($Arr) > 0) $FillValue = end($Arr);
		
		// The specified size is larger than the source array, append elements to the source array and return the results.
		return array_pad($Arr, $ArrCount, $FillValue);
		
	}	


The Captian
Today they call you "crazy". Tomorrow they call you "ahead of your time."
Global Skywatch Learn about Chemtrails - You're breathing them now!
OnlyTheBestHerbs.com World-class supplements
Mercury Talk Why you are sick.
OneUp Domains Domains, Hosting, Email
1-800-358-4278 (U.S. & Canada)