Write program to emulate the function call str_pad($myString, $desiredLength)
Take a string, and add space characters to the right of it until the string reaches the desired length.
Display both the original and padded string in the page.
Use a while loop to keep adding spaces to the right of the string until the desired length is reached.
<?php $myString = "Hello, world!"; $desiredLength = 20;//from w ww . j a v a2s. c o m echo "Original string:'$myString' \n"; while (strlen($myString) < 20) { $myString .= " "; } echo "Padded string: '$myString'"; ?>