Last active
June 15, 2021 15:16
-
-
Save geirman/eb0302e242c13755a4f2 to your computer and use it in GitHub Desktop.
How to Pad a String with Zeros in ColdFusion
This file contains 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
<cfscript> | |
/* | |
Try It Here: | |
http://www.trycf.com/scratch-pad/gist/eb0302e242c13755a4f2 | |
*/ | |
writeOutput( pad('123', 5) ); | |
function pad( str, n ){ | |
return replace( RJustify( str, n ), ' ', '0', 'all' ); | |
} | |
</cfscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You may want to specifically cast it as a string... you never know when ColdFusion will interpret values as numeric and drop the zeros.