Hi im trying to build a function to work out string length if not a certain size than it adds to it to make it the right size, im a newbie trying to get it done but need some help pls.
/ function to work out string length
and add to it ti make it so many characters as set out
by max_length with a 0 at the beginning ie 127 to 00000127
/
function calcsize($numberdata) {
$max_length = 8;
if (strlen($numberdata) < $max_length) {
$actuallength = strlen($numberdata);
$difference = $max_length - $actuallength;
echo " $numberdata string is to small, <BR> length is $actuallength so diiference is $difference<br>";
for ($ii=0;$ii<$difference;$ii++) {
$w = $ii;
$w = "0";
echo "$w";
}
echo "";
}
else {
echo "its fine";
}
}
calcsize ("12678");