|  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #32989 str_pad and str_repeat return wrong string
Submitted: 2005-05-09 17:10 UTC Modified: 2005-05-09 18:56 UTC
From: gclift at gtsquared dot com Assigned:
Status: Not a bug Package: Strings related
PHP Version: 4.3.11 OS: Linux 2.4.21-27.0.2.ELsmp #1
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
Block user comment
Status: Assign to:
Bug Type:
From: gclift at gtsquared dot com
New email:
PHP Version: OS:


 [2005-05-09 17:10 UTC] gclift at gtsquared dot com
str_pad returns the exact same string that was entered as the string input.

str_repeat returns 0 length string.

'./configure' '--localstatedir=/var/hsphere/php' '--with-apxs=/hsphere/shared/apache/bin/apxs' '--with-openssl=/usr' '--with-zlib=/usr' '--with-zlib-dir=/usr' '--with-bz2=/usr' '--enable-calendar' '--with-jpeg-dir=/usr' '--enable-ftp' '--with-gd' '--with-ttf' '--with-freetype-dir=/usr' '--enable-gd-native-ttf' '--with-png-dir=/usr' '--with-gettext=/usr' '--with-imap=/hsphere/shared' '--with-mysql=/usr' '--with-pgsql=/usr' '--with-curl=/hsphere/shared' '--with-curlwrappers' '--with-mhash=/usr' '--with-iconv=/hsphere/shared' '--enable-sockets' '--with-zip=/usr' '--enable-versioning' '--enable-track-vars' '--enable-trans-sid' '--enable-bcmath' '--enable-mbstring' '--disable-debug'

Reproduce code:
echo "<br>Start Test!<br>";
echo "<pre>";

var_dump( str_repeat(4, "../") );
echo "\r\n";
var_dump( str_pad("TESTING", 6, "../", STR_PAD_LEFT) );
echo "\r\n";
var_dump( str_pad("TESTING", 6, "-==") );
echo "\r\n";
var_dump( str_pad("TEST", 4) );

echo "</pre>";
echo "<br>End Test!<br>";


Expected result:
Start Test!

string(0) "../../../../"

string(7) "../../../../../TESTING"

string(7) "TESTING-==-==-==-==-==-=="

string(4) "TEST    "

End Test!

Actual result:
Start Test!

string(0) ""

string(7) "TESTING"

string(7) "TESTING"

string(4) "TEST"

End Test!


Add a Patch

Pull Requests

Add a Pull Request


AllCommentsChangesGit/SVN commitsRelated reports
 [2005-05-09 18:56 UTC]
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at and the instructions on how to report
a bug at

Read the manual again, pay close attention to the examples and the order of parameters.
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Apr 23 18:01:34 2024 UTC