Re: Add spaces to a string
| From: | Robert Cummings | Date: | Thu, 28 Oct 2004 13:40:17 +0000 |
| Subject: | Re: Add spaces to a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-200535@lists.php.net to get a copy of this message | ||
On Thu, 2004-10-28 at 09:32, Phpu wrote:
> How to add a specified number of spaces to a string
>
> I use this but won't work if $spaces is less than the length of the $string
>
> $string = "bla bla bla";
> $spaces = 5;
> $string = str_pad($string, $spaces, " ");
Assuming you don't want padding since the above doesn't generate what
you want... try the following:
$string = "bla bla bla";
$spaces = 5;
$string .= str_repeat( ' ', 5 );
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'