RE: [PHP] Zero Fill -> Number Format
| From: | Mike Brum | Date: | Wed, 19 Mar 2003 23:15:47 +0000 |
| Subject: | RE: [PHP] Zero Fill -> Number Format | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-140359@lists.php.net to get a copy of this message | ||
This is what I did for a dynamic zero-fill for renaming batches of files:
// Get "Zero Padding" For New Image Names
$zero_padding = strlen(count($image_array));
foreach($image_array as $temp){
$n++;
$n_length = strlen($n);
for($i = 0; $i < ($zero_padding - $n_length); $i++){
$n = "0" . $n;
}
$new_name = $image_inbox . "/" . $newName . "-" . $n . ".jpg";
rename("$image_inbox/$temp", $new_name);
}
I'm not sure if this will be applicable to your situation, but it works
perfectly for me since it will zero-fill for any length of numbers and pad
the shorter numbers appropriately.
-M
-----Original Message-----
From: Harry.de [mailto:harald.mohring@gmx.de]
Sent: Wednesday, March 19, 2003 6:09 PM
To: php-general@lists.php.net
Subject: [PHP] Zero Fill -> Number Format
How can I put out a Zero Fill for numbers
The result should be
$something=26;
echo $something;
e.g.
0000026
I didn't found a solution with number format. Is there any other way?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php