ID: 43829 Updated by: [EMAIL PROTECTED] Reported By: l dot nanetti at rug dot nl -Status: Open +Status: Bogus Bug Type: Strings related Operating System: windows PHP Version: 5.2.5 New Comment:
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php . Previous Comments: ------------------------------------------------------------------------ [2008-01-13 21:10:56] public dot chris at web dot de isn' t a bug. browser shows just one space. look at the source. use the following code using htmlentities $mystring = 'Luca Nanetti'; $formatstring = "[%30s]"; $fstring = sprintf($formatstring, $mystring); $fstring = str_replace(' ', ' ', $fstring); echo $fstring; or replace echo $fstring; by following echo '<pre>' . $fstring . '</pre>'; ------------------------------------------------------------------------ [2008-01-13 19:46:55] l dot nanetti at rug dot nl Description: ------------ what I want to do: left-padding a string with spaces. In this example, up to 30 charachters. code snippet: <?php $mystring = 'Luca Nanetti'; $formatstring = "[%30s]"; $fstring = sprintf($formatstring, $mystring); echo $fstring; ?> expected: [ Luca Nanetti] what I get is instead a one-charachter padding, i.e. the string is left padded with only one space: [ Luca Nanetti] it successfully works with the number 0: using "[%030s]" I get [000000000000000000Luca Nanetti] it successfully works with custom padding, "[%'#30s]" Additional informations: - Abyss web server, accessed locally on 127.0.0.1:8000 - modules: PDO, PDO_SQLITE, MCRYPT Reproduce code: --------------- <?php $mystring = 'Luca Nanetti'; $formatstring = "[%30s]"; $fstring = sprintf($formatstring, $mystring); echo $fstring; ?> Expected result: ---------------- [ Luca Nanetti] Actual result: -------------- [ Luca Nanetti] ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=43829&edit=1