Is it possible to pad a varible?

I’m creating a basic IVR system that collects users inputs into what will ultimately be a fixed field text file.

I’ve got my dialplan all setup and it’s accepting input. I collect basic info,

Press 1 for yes 2 for no
enter your phone number
enter time in hr
enter time in min
enter time in sec

then i have a loop i built that will collect how many different items they selected.
Enter Items selected : they can select up to 10 different items using digits 1-99

I’m using system (echo etc…) to create the txt file.

One thing I’m stuck on is trying to get the fields to line up correctly.
I can line up everything except the loop for the items they selected. Some can enter 2 items others can select all ten. and other can select 7 or 5 or 3 etc…

Of course I thought of changing this to a comma delimited .csv file however right now I cannot as the program that looks at the file after it’s created is stuck with using fixed field lengths.

So What I’d like to see happen is some way to pad out the selection after the items they selected.
It should fill up to 20 spaces
IE: 23121323******** or 23****************** or 232111245*****

Is there a way you can tell a custom variable to pad the end out to certain characters?

Thanks in advance for your help!

If you have PHP installed on the system asterisk is installed on you could do it like this:

/var/www/padvar.php

<?php echo str_pad($_GET['in'],20,"*"); ?>

and then you could pad things as in the example below:

${SHELL(curl http://localhost/padvar.php?in=23*12*23)}