#43829 [NEW]: string padding doesn't work with default
From: l dot nanetti at rug dot nl
Operating system: windows
PHP version: 5.2.5
PHP Bug Type: Strings related
Bug description: string padding doesn't work with default
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 bug report at http://bugs.php.net/?id=43829&edit=1
--
Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=43829&r=trysnapshot44
Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=43829&r=trysnapshot52
Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=43829&r=trysnapshot53
Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=43829&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=43829&r=fixedcvs
Fixed in release: http://bugs.php.net/fix.php?id=43829&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=43829&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=43829&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=43829&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=43829&r=support
Expected behavior: http://bugs.php.net/fix.php?id=43829&r=notwrong
Not enough info: http://bugs.php.net/fix.php?id=43829&r=notenoughinfo
Submitted twice: http://bugs.php.net/fix.php?id=43829&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=43829&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=43829&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=43829&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=43829&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=43829&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=43829&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=43829&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=43829&r=mysqlcfg
Thread (3 messages)
- l dot nanetti at rug dot nl