note 77659 deleted from function.sprintf by cmb

From: Date: Sun, 19 Jan 2020 08:44:28 +0000
Subject: note 77659 deleted from function.sprintf by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-213924@lists.php.net to get a copy of this message
Note Submitter: me at umarfarooq dot net ---- /** 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; }

« previous php.notes (#213924) next »