like this:

$digit = 122;
 $digits = sprintf ("%08d", $digit);
 print $digits;

Greets,

Edward


----- Original Message -----
From: "Jeff Sheltren" <[EMAIL PROTECTED]>
To: "Andy" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Saturday, February 02, 2002 6:41 PM
Subject: Re: [PHP] Adding 6 digits to a str?


> Why is it that you want to represent an int with leading 0's?  Is it just
> to print it out that way?  If that is the case, then you can use the
printf
> function for formatted printing.
>
>
> Jeff
>
> At 10:53 AM 2/2/2002 +0100, Andy wrote:
> >Hi guys,
> >
> >I am trying to force a int to be 8 digits. If it is only 3 dig filling
the
> >first ones with 0.
> >
> >Anyhow I tryed it with type casting, but it does not matter what I try, I
> >always get an addition.
> >
> >E.g:
> >   $member_id is: 136
> >    should be: 00000136
> >
> >Here is the code, which is still returning 136:
> >
> >    for($i=0;$i<count($member_id);$i++){
> >        $length = strlen($member_id[$i]);
> >
> >         settype ($member_id[$i], "string");
> >         $zero = '0';
> >         settype ($zero, "string");
> >
> >         $member_id[$i] = $zero + $member_id[$i];
> >         echo $member_id[$i];
> >    }
> >
> >Does anybody know how to solve this thing??
> >
> >Thanx Andy
>
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to