Strings Php

Array(50,60,44,null,3);
To this
Array(050,060,044,000,003);
This could be usefull for example when you test user data with database values, or to do any math calculus ...
/**
* Return zerofilled value
*
* @param integer $field
* @param integer $digits
* @return string
*/
function zerofilled($field, $digits = 3){
$n = strlen($field);
if ($n<=$digits) {
for ($i = 1;$i<=($digits-$n);$n++)
$field = "0$field";
}
return $field;
}
// sample usage
$data = array(50,60,44,null,3);
foreach ($data as $k=>$v) {
echo "result $k = ".zerofilled($v,2)."\n";
}
?>