Again, it doesn't work with negative numbers...
<?
$input = -1;
echo str_pad($input, 3, "0", STR_PAD_LEFT);
?>
Will output: 0-1
But this :
<?
$intNombre = -1;
$intMultiple = 1;
if($intNombre < 0) {
$intNombre *= -1;
$intMultiple = -1;
}
$strNombre = str_pad($intNombre, 3, "0", STR_PAD_LEFT);
if($intMultiple == - 1) {
$strNombre = "-" . $strNombre;
}
echo $strNombre;
?>
will output: -001.