CFLib.org – Common Function Library Project

arrayExcludeString(aObj)

Last updated July 11, 2006
Download UDF

author

Marcos Placona                                    Marcos Placona

Version: 1 | Requires: ColdFusion MX | Library: DataManipulationLib

Description:
This UDF is to be used when you need to remove all the string values from your array. It removes them and return a clean array with just numbers.

Return Values:
Returns an array.

Example:

<cfset aTest = arrayNew(1) />
<cfset aTest[3] = 22 />
<cfset aTest[1] = "Marcos" />
<cfset aTest[2] = "Placona" />
<cfset aTest[3] = 22 />
<cfset aTest[4] = "www.cfdevelopers.com.br">
<cfset aTest[5] = 55>
<cfset aTest[6] = "test">
<cfset aTest[7] = "11">
<cfset aTest[8] = "135">
<cfset aTest[9] = "test">
<cfset aTest[10] = "25">


<cfdump var="#arrayExcludeNumeric(aTest)#">

Parameters:

Name Description Required
aObj Array to filter. Yes

Full UDF Source:

<!---
Excludes string items from an array.

@param aObj      Array to filter. (Required)
@return Returns an array.
@author Marcos Placona (marcos.placona@gmail.com)
@version 1, July 11, 2006
--->

<cffunction name="arrayExcludeString" returntype="array">
    <cfargument name="aObj" type="array" required="Yes">
    <cfset var ii = "">
    
    <!--- Looping through the array --->
    <cfloop to="1" from="#arrayLen(aObj)#" index="ii" step="-1">
        <!--- Checking if it's a number --->
        <cfif not isNumeric(aObj[ii])>
            <cfset arrayDeleteAt(arguments.aObj, ii) />
        </cfif>
    </cfloop>
    
    <cfreturn aObj />
</cffunction>

Search CFLib.org


Latest Additions

Raymond Compton Raymond Compton added
structBlend
19 day(s) ago

Duncan Duncan added
IsZIPUK
19 day(s) ago

Todd Sharp Todd Sharp added
getTagContentAll
25 day(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Gerald Guido Gerald Guido added
ListReturnDuplicat...
1 month(s) ago

Created by Raymond Camden / Design by Justin Johnson