SCook Posted October 30, 2008 Share Posted October 30, 2008 Hi all, Got another tone :-) Is there a built in function to format a number to it's appropirate suffix? I'm sure there is, and it'd save me time to write my own function, like: 1 = 1st 3 = 3rd 51 = 51st and etc. Thanks Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted October 30, 2008 Share Posted October 30, 2008 You can use the date() function for numbers between 1 and 31. After that you're on your own: <?php for ($i=1;$i<32;$i++) echo date('jS',strtotime('2008-01-' . $i)) . '<br>'; ?> Ken Quote Link to comment Share on other sites More sharing options...
thebadbad Posted October 30, 2008 Share Posted October 30, 2008 You can find some functions in the comments of the is_numeric() manual. Quote Link to comment Share on other sites More sharing options...
SCook Posted October 30, 2008 Author Share Posted October 30, 2008 Well, I suppose I can use the date function, I've thought of that. What I suppose I can do is split the number string and apply the date to the final digit, as this is the only thing that matters. However, ou run into a weierd problem with the teens. They're all "th" So I guess I'll have to figure something out. Maybe the is_mumeric can help Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.