Forum Moderators: coopster

Message Too Old, No Replies

Cropping a number to the last five digits

         

Jeremy_H

7:48 am on Mar 3, 2006 (gmt 0)

10+ Year Member



Hello,

I have a number variable of possible different lengths that I would like to crop to the last five digits.

I've been trying to search php.net, Google, and other databases by various words, such as number trim, number crop, number truncate, etc, but I just can't find the solution.

Does anybody know if this is possible, and if so, how one might be able to do it?

Thanks

omoutop

8:04 am on Mar 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



You need to use substr() function. Refer to php manual on more info on this

dreamcatcher

8:46 am on Mar 3, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yep, substr as omoutop mentioned.

$string = 'abcdefghijklmnopqrstuvwxyz':

echo substr($string,-5);

Would print:

vwxyz

dc

Jeremy_H

5:10 pm on Mar 3, 2006 (gmt 0)

10+ Year Member



Thank you guys so much,

It works great!