note 77658 added to function.sprintf
| From: | me at umarfarooq dot net | Date: | Fri, 07 Sep 2007 06:28:50 +0000 |
| Subject: | note 77658 added to function.sprintf | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130284@lists.php.net to get a copy of this message | ||
/**
This function returns a formated string with the legnth you specify
@string holds the string which you want to format
@len holds the length you want to format
**/
function formatString($string, $len)
{
if (strlen($string) < $len)
{
$addchar=($len - strlen($string)) ;
for ($i = 0; $i < $addchar; $i++)
{
$string=sprintf("$string%s", "0");
}
}
if (strlen($string) > $len)
{
$string=substr($string,0,$len);
}
return $string;
}
----
Server IP: 69.147.83.197
Probable Submitter: 202.163.69.60
----
Manual Page -- http://www.php.net/manual/en/function.sprintf.php
Edit -- https://master.php.net/note/edit/77658
Del: integrated -- https://master.php.net/note/delete/77658/integrated
Del: useless -- https://master.php.net/note/delete/77658/useless
Del: bad code -- https://master.php.net/note/delete/77658/bad+code
Del: spam -- https://master.php.net/note/delete/77658/spam
Del: non-english -- https://master.php.net/note/delete/77658/non-english
Del: in docs -- https://master.php.net/note/delete/77658/in+docs
Del: other reasons-- https://master.php.net/note/delete/77658
Reject -- https://master.php.net/note/reject/77658
Search -- https://master.php.net/manage/user-notes.php