Monkuar Posted October 31, 2012 Share Posted October 31, 2012 16457 should be 16,457 1169 should be 1,169 would look way more professional IMO, what do you guys think? Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/ Share on other sites More sharing options...
requinix Posted October 31, 2012 Share Posted October 31, 2012 Casting "16,457" to int gives 16. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389069 Share on other sites More sharing options...
ManiacDan Posted October 31, 2012 Share Posted October 31, 2012 Eh, looks ok to me. Once you start using thousands separators you run into internationalization issues and other stuff. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389070 Share on other sites More sharing options...
Philip Posted October 31, 2012 Share Posted October 31, 2012 Dan is correct. Once you start formatting it you run into internationalization issues (. vs ,). The only place it bothers me at all is in the admin area, where we have stats and such and with larger numbers (in the millions.) That's a little hard to read, but nothing major. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389095 Share on other sites More sharing options...
salathe Posted October 31, 2012 Share Posted October 31, 2012 I vote for hiding the numbers. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389096 Share on other sites More sharing options...
Christian F. Posted October 31, 2012 Share Posted October 31, 2012 Don't forget spaces, Philip: There are a few of us who're using them as thousands separators too. Though, that said it's (should be) quite easy to add a selectable pattern for the number format, just like with the date. Depending upon how the actual code looks for the forum looks like, and if anyone has any time and desire to make it. I know I don't. As far as I care the post count could just be hidden in the profile or something, or not shown at all. The only thing I care about at all is the number of posts per day, and that's only for fun. Shame it disappeared in the forum switch, but... Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389101 Share on other sites More sharing options...
Philip Posted October 31, 2012 Share Posted October 31, 2012 Don't forget spaces, Philip: There are a few of us who're using them as thousands separators too. WHYYYYYYYYYYY Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389103 Share on other sites More sharing options...
Christian F. Posted October 31, 2012 Share Posted October 31, 2012 (edited) Just to bug you. *Christian runs. Edited October 31, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389108 Share on other sites More sharing options...
Philip Posted October 31, 2012 Share Posted October 31, 2012 Dumb question though, when do you know it is a new number? E.g. 234 567 890 - how would you know that it is 2 numbers, 234 and 567,890 and not 234,567,890? Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389109 Share on other sites More sharing options...
ManiacDan Posted October 31, 2012 Share Posted October 31, 2012 234 and 567,890 and not 234,567,890? I believe you mean 567.890 and not 234.567.890 Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389112 Share on other sites More sharing options...
Christian F. Posted October 31, 2012 Share Posted October 31, 2012 (edited) We use comma to separate numbers, as well as the word "eller" (same as "or" in English). Just like with any other list. 2 numbers: 123 eller 456 789 3 numbers: 123, 456 eller 789 2 numbers, with decimals: 12,3 eller 45 678,9 3 numbers, with decimals 1 000,4, 223 342,88 eller 1,2 See, perfectly logical. No? Edited October 31, 2012 by Christian F. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389124 Share on other sites More sharing options...
Philip Posted October 31, 2012 Share Posted October 31, 2012 The first 3 make sense, the last though... man... I'd likely make a lot of mistakes. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389126 Share on other sites More sharing options...
fenway Posted November 1, 2012 Share Posted November 1, 2012 Just use underscores, like Perl. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389183 Share on other sites More sharing options...
.josh Posted November 1, 2012 Share Posted November 1, 2012 how about we convert it to word representation? 8388607 posts = eight million three hundred eighty eight thousand six hundred seven. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389317 Share on other sites More sharing options...
ManiacDan Posted November 1, 2012 Share Posted November 1, 2012 (edited) I dare you: <?php //new and improved recursive version of my last attempt: function dec2english($number) { if ( !is_string($number) && !is_float($number) && !is_int($number) ) { return false; } if ( is_string($number) ) { //we know it's a string. see if there's a negative: if ( substr($number, 0, 1) == '-' ) { $number = substr($number, 1); $number = $number * -1; } } $number = strval($number); if ( $number == '0' ) { return "Zero"; } $negative = $number < 0 ? "Negative" : ""; $number = trim($number, '-'); $split_by_decimal = explode(".", $number); $decimal_string = ''; if ( count($split_by_decimal) > 1 ) { $decimal_string = process_decimal($split_by_decimal[1]); } return trim(preg_replace("#\s+#", " ", $negative . " " . process_number($split_by_decimal[0]) . " " . $decimal_string)); } function process_number($number, $depth = 0) { $group_designators = array( "", "Thousand", "Million", "Billion", "Trillion", "Quadrillion", "Quintillion", "Sextillion", "Septillion", /*that's enough for now*/); $numbers = array( '1'=>"One", '2'=>"Two", '3'=>"Three", '4'=>"Four", '5'=>"Five", '6'=>"Six", '7'=>"Seven", '8'=>"Eight", '9'=>"Nine", '10'=>"Ten", '11'=>"Eleven", '12'=>"Twelve", '13'=>"Thirteen", '14'=>"Fourteen", '15'=>"Fifteen", '16'=>"Sixteen", '17'=>"Seventeen", '18'=>"Eighteen", '19'=>"Nineteen", '20'=>"Twenty", '30'=>"Thirty", '40'=>"Forty", '50'=>"Fifty", '60'=>"Sixty", '70'=>"Seventy", '80'=>"Eighty", '90'=>"Ninety", ); //we already know that we have a numeric string. Process it in groups of three characters while ( strlen($number) > 0 ) { if ( strlen($number) <= 3 ) { $number_to_process = $number; $number = ''; } else { $number_to_process = substr($number, strlen($number) - 3); $number = substr($number, 0, strlen($number) - 3); } if ( strlen($number_to_process) == 3 ) { $output[] = $numbers[substr($number_to_process, 0, 1)]; $output[] = "Hundred"; $number_to_process = substr($number_to_process, 1); } if ( isset($numbers[$number_to_process]) ) { $output[] = $numbers[$number_to_process]; } else { //we're dealing with a number greater than 20 and not divisible by 10: $tens = substr($number_to_process, 0, 1) . "0"; $ones = substr($number_to_process, 1, 1); $output[] = isset($numbers[$tens]) ? $numbers[$tens] : ''; $output[] = $numbers[$ones]; } return process_number($number, $depth+1) . " " . implode(" ", $output) . " " . $group_designators[$depth]; } } function process_decimal($number) { $suffix = array( "Tenths", "Hundreths", "Thousandths", "Ten Thousandths", "Hundred Thousandths", "Millionths", //enough ); return " and " . process_number($number) . $suffix[strlen($number) - 1]; } echo dec2english("-19832498347.34") . "\n"; echo dec2english(14.12) . "\n"; echo dec2english(1432489723485) . "\n"; echo dec2english(10234.45645) . "\n"; echo dec2english(-10.2) . "\n"; echo dec2english("1298721498732.111111") . "\n"; Edited November 1, 2012 by ManiacDan spacing is all weird Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389320 Share on other sites More sharing options...
.josh Posted November 1, 2012 Share Posted November 1, 2012 well for starters, we could water that down, since post count should never be a negative number or have decimals. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389342 Share on other sites More sharing options...
Philip Posted November 1, 2012 Share Posted November 1, 2012 I don't think there is enough room for mine on the skin: Eight million three hundred eighty eight thousand six hundred seven Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389353 Share on other sites More sharing options...
ManiacDan Posted November 1, 2012 Share Posted November 1, 2012 well for starters, we could water that down, since post count should never be a negative number or have decimals. I wrote that years ago, just copied and pasted it here. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389363 Share on other sites More sharing options...
Jessica Posted November 1, 2012 Share Posted November 1, 2012 I don't think there is enough room for mine on the skin: It'll fit. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389375 Share on other sites More sharing options...
Philip Posted November 1, 2012 Share Posted November 1, 2012 It'll fit. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389379 Share on other sites More sharing options...
Jessica Posted November 1, 2012 Share Posted November 1, 2012 should't "eighty eight" read "eighty-eight"? Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389381 Share on other sites More sharing options...
.josh Posted November 1, 2012 Share Posted November 1, 2012 I wrote that years ago, just copied and pasted it here. yah i figured...didn't think you busted that out within minutes as a specific response! Was just sayin' in general if we were to do it... Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389383 Share on other sites More sharing options...
Psycho Posted November 1, 2012 Share Posted November 1, 2012 I vote for converting to binary. The presentation display for that is the same for everyone, right? Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389387 Share on other sites More sharing options...
ManiacDan Posted November 1, 2012 Share Posted November 1, 2012 should't "eighty eight" read "eighty-eight"? According to the Chicago Manual of Style, yes. Lucky for you this script is open source. Get to it. Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389393 Share on other sites More sharing options...
ignace Posted November 1, 2012 Share Posted November 1, 2012 (edited) I vote for converting to binary. The presentation display for that is the same for everyone, right? echo base_convert($postCount, 10, 36); For ultimate geekiness: if we use a custom BigInteger library we can even go as far as base-62. Edited November 1, 2012 by ignace Quote Link to comment https://forums.phpfreaks.com/topic/270120-formatting-post-numbers/#findComment-1389401 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.