Jump to content
Sign in to follow this  

Expand strings to a predetermined length?

Recommended Posts


I need to expand a string to a predetermined length using a fill character. In this case, I'm reading a CSV file, and I need to take the employee number, which can be anywhere between 3 and 6 characters, and expand it to eight using leading zeros.

My current method uses a Switch statement, but I was wondering if there was a UDF I had overlooked, or a more elegant or clever way to go about it than:

Switch StringLen($empNum[$i])
Case 2
Case 3
Case 4
Case 5
Case 6
Case 7
Case 8

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this