pkedpker Posted June 17, 2009 Share Posted June 17, 2009 Alright I posted many questions today.. and all of them are pretty pathetic. in this one i want a number formatter that keeps zero padding in front. like with number 3, 57, 183, 9 , 90, 900 would look like 003,057, 183, 009, 090, 900. is there such a function? I know it's easily made by hand with strlen and a switch but i'm looking for built in functions. Link to comment https://forums.phpfreaks.com/topic/162489-solved-number-format-function/ Share on other sites More sharing options...
akitchin Posted June 17, 2009 Share Posted June 17, 2009 see str_pad() or sprintf(). Link to comment https://forums.phpfreaks.com/topic/162489-solved-number-format-function/#findComment-857615 Share on other sites More sharing options...
pkedpker Posted June 17, 2009 Author Share Posted June 17, 2009 yup str_pad i was looking at right after I posted this topic yah that should it.. function number_pad($number,$n) { return str_pad((int) $number,$n,"0",STR_PAD_LEFT); } but what about sprintf isn't that just like the C function just for appending strings with certain datatypes to a main string Thanks It's solved for now. Link to comment https://forums.phpfreaks.com/topic/162489-solved-number-format-function/#findComment-857616 Share on other sites More sharing options...
EchoFool Posted June 17, 2009 Share Posted June 17, 2009 Please click the topic solved thank you Link to comment https://forums.phpfreaks.com/topic/162489-solved-number-format-function/#findComment-857621 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.