Don’t do that: You want to add exactly 20 whitespaces on the left side of a string :
$twentyWhitespaces = ' steve'
The length of the variable $twentyWhitespaces is 25 – 5 (steve) = 20 whitespaces
Do that: The above code works well but it is definitely not practical to manually count the number of whitespaces to add and human errors can occur.
In the String class, there is a .NET method PadLeft() which can be useful in this case:
$padLeft = 'steve'.PadLeft(25)
We get the same results with less effort and more reliability:
It is possible to replace the whitespace by a character: PadLeft(Int32, Char)
Note: The PadRight() method is also available.