This is a discussion on str_pad within the PHP General forums, part of the PHP Programming Forums category; This should be quite an easy task for some... say for example $line->dbranch has a value of 3 ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
This should be quite an easy task for some...
say for example $line->dbranch has a value of 3 I know that 3 spaces will be added on to the end of $dbranch $dbranch = str_pad($line->dbranch_no, 6); so the value of $dbranch should look like "3 " Is there anyway to right justify the 3 using str_pad .. example still put the 3 spaces in but at the beginning??? so it looks like " 3" Chris |
|
|||
|
of course, you can specify the optional argument STR_PAD_LEFT like:
$dbranch = str_pad($line->dbranch_no, 6, '', STR_PAD_LEFT); Enjoy, Nitin ----- Original Message ----- From: "Chris Grigor" <aphrodit@iafrica.com> To: "php" <php-general@lists.php.net> Sent: Friday, September 26, 2003 4:49 PM Subject: [php] str_pad This should be quite an easy task for some... say for example $line->dbranch has a value of 3 I know that 3 spaces will be added on to the end of $dbranch $dbranch = str_pad($line->dbranch_no, 6); so the value of $dbranch should look like "3 " Is there anyway to right justify the 3 using str_pad .. example still put the 3 spaces in but at the beginning??? so it looks like " 3" Chris |