Re: Adding 6 digits to a str?

From: Date: Sun, 03 Feb 2002 21:09:45 +0000
Subject: Re: Adding 6 digits to a str?
References: 1 2  Groups: php.general 
Request: Send a blank email to php-general+get-83331@lists.php.net to get a copy of this message
thanx!!! "John Lim" <heyjohnlim@yahoo.com> schrieb im Newsbeitrag news:20020203154002.3109.qmail@pb1.pair.com... > Try http://php.net/str_pad > > Andy <news.letters@gmx.de> wrote in message > news:20020202173059.82517.qmail@pb1.pair.com... > > 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 > > > > > > > > > >

« previous php.general (#83331) next »