Created
March 22, 2014 11:39
-
-
Save boughtonp/9705827 to your computer and use it in GitHub Desktop.
StructToQueryString
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<cffunction name="StructToQueryString" returntype="String" output=false access="public" | |
hint="Converts a struct into a url-encoded querystring." | |
> | |
<cfargument name="Data" type="Struct" required=true /> | |
<cfset var QS = '' /> | |
<cfif NOT StructCount(Arguments.Data)><cfreturn '' /></cfif> | |
<cfloop item="local.Key" collection=#Arguments.Data#> | |
<cfif NOT StructKeyExists(Arguments.Data,Key) ><cfcontinue /></cfif> | |
<cfset QS &= '&' & encodeForUrl(Key) & '=' & encodeForUrl(Arguments.Data[Key]) /> | |
</cfloop> | |
<cfreturn QS.substring(1) /> | |
</cffunction> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment