|
Posted by Tom on 05/25/07 17:55
<alpha.beta0@googlemail.com> wrote in message
news:1180112733.002880.170520@w5g2000hsg.googlegroups.com...
> I set it to 001 at start but the next number PHP produces is
> 2,3,4,5,etc. instead of 002,003,004,005,etc.
>
> What will I need to change to get the latter?
>
> ===
>
> $Count = 001;
>
> foreach($Replace_With_List as $Replace_With)
> {
> ++$Count;
> }
>
> ===
>
The problem is "001" is a string of text, not a real number. Maybe use the
"strlen" function to determine the length in characters, then add to the
beginning of the string if needed.
<?php
$Count = 1;
foreach($Replace_With_List as $Replace_With)
{
++$Count;
}
if(strlen($Count) == 1)
{
$Count = '00' . $count;
}
elseif(strnlen($Count) == 2)
{
$Count = '0' . $count;
}
?>
Tom
--
Newsguy Internet Access
$9.95 / mo. or $79.95 / yr.
http://newsguy.com/allinone.htm
Navigation:
[Reply to this message]
|