We have a “potential” 7 digit number that we need to break into 7 separate variables. If it is a 4 digit number, then the other 3 digits should be empty. As an example:
$total = 12345
$var1 = ""
$var2 = ""
$var3 = "1"
$var4 = "2"
$var5 = "3"
$var6 = "4"
$var7 = "5"
Anyone have any ideas on the best way to do this?
Thanks in advance.
Split, then pad:
See output.
And if you absolutely need 7 variables:
But I strongly suggest using an array.