ordinals

PHP: increment counter function using words (i.e. First, Second, Third, etc.. )

流过昼夜 提交于 2019-12-19 15:39:13
问题 I've been trying to find a function which increments a counter using words. I know its possible using numbers with suffixes (i.e. 1st, 2nd, 3rd and so on). Here is a snippet of the code i've got: function addOrdinalNumberSuffix($num) { if (!in_array(($num % 100),array(11,12,13))){ switch ($num % 10) { // Handle 1st, 2nd, 3rd case 1: return $num.'st'; case 2: return $num.'nd'; case 3: return $num.'rd'; } } return $num.'th'; } Code Source But is there a way to replicate this with words (i.e

Convert ordinal number to string [duplicate]

为君一笑 提交于 2019-12-13 03:51:02
问题 This question already has answers here : Is there a way in Java to convert an integer to its ordinal? (12 answers) Closed last year . I am retrieving ordinal numbers using below code: public static String ordinal(int i) { String[] sufixes = new String[] { "th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th" }; switch (i % 100) { case 11: case 12: case 13: return i + "th"; default: return i + sufixes[i % 10]; } } Output : 1st, 2nd, 3rd... How can I get string like first, second, third

Add Ordinal Suffix to WordPress Counter

我的未来我决定 提交于 2019-12-11 17:54:14
问题 I am trying to add ordinal suffixes to a WordPress Post Counter that I am building for a ranking board. Here is the code I currently have. <?php if(have_posts()): $counter = 1; query_posts('post_type=rushmoor&meta_key=subaru_driver_best_lap&orderby=meta_value_num&order=asc'); while(have_posts()):the_post();?> <?php $driver_best_lap = get_post_meta( get_the_ID(), 'subaru_driver_best_lap', true );?> <li> <div class="name"><?php echo $counter;?> <?php the_title();?></div> <div class="lap-time"><

How to convert Cardinal numbers into Ordinal ones

血红的双手。 提交于 2019-12-08 16:23:23
问题 Is there an easy way to convert the number 1, 2, 3, ... to "1st", "2nd", "3rd", ..., and in such a way that I can give the function a language and have it return me the correct form for the language I'm targeting? Either standard C++ (stl or boost OK), MFC or ATL, win32 api or a small, single-purpose and free library that I can download from somewhere. Thanks. 回答1: I doubt whether it is possible at all, since in many languages this form will depend on the context, like gender or case of the

Modify regex to match dates with ordinals “st”, “nd”, “rd”, “th”

大兔子大兔子 提交于 2019-12-08 07:26:00
问题 How can the regex below be modified to match dates with ordinals on the day part? This regex matches "Jan 1, 2003 | February 29, 2004 | November 02, 3202" but I need it to match also: "Jan 1st, 2003 | February 29th, 2004 | November 02nd, 3202 | March 3rd, 2010" ^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\ (0?[1-9]|([12]\d)|30))|(Feb(ruary)?\ (0?[1-9]|1\d|2[0-8]|(29

Modify regex to match dates with ordinals “st”, “nd”, “rd”, “th”

与世无争的帅哥 提交于 2019-12-07 07:54:28
How can the regex below be modified to match dates with ordinals on the day part? This regex matches "Jan 1, 2003 | February 29, 2004 | November 02, 3202" but I need it to match also: "Jan 1st, 2003 | February 29th, 2004 | November 02nd, 3202 | March 3rd, 2010" ^(?:(((Jan(uary)?|Ma(r(ch)?|y)|Jul(y)?|Aug(ust)?|Oct(ober)?|Dec(ember)?)\ 31)|((Jan(uary)?|Ma(r(ch)?|y)|Apr(il)?|Ju((ly?)|(ne?))|Aug(ust)?|Oct(ober)?|(Sept|Nov|Dec)(ember)?)\ (0?[1-9]|([12]\d)|30))|(Feb(ruary)?\ (0?[1-9]|1\d|2[0-8]|(29(?=,\ ((1[6-9]|[2-9]\d)(0[48]|[2468][048]|[13579][26])|((16|[2468][048]|[3579][26])00)))))))\,\ ((1[6-9

localize ordinal numbers

∥☆過路亽.° 提交于 2019-12-05 09:35:44
for ($rank=0; $rank<100; $rank++) { printf("Your rank: %d%s", $rank, $suffix); } Does there exist a gettext function to localize $suffix to the current language and return, for example: Your rank: 0th Your rank: 1st Your rank: 2nd Your rank: 3rd Your rank: 4th if the current locale is English, and whatever the correct "ordinal" forms of numbers are in other languages when the locale is set to something else? Thank you. Gordon Not that I know of, but you can use NumberFormatter $nf = new NumberFormatter('en_US', NumberFormatter::ORDINAL); print $nf->format(123); // prints 123rd Source:

Javascript: Ordinal suffix for numbers with specific CSS class

时间秒杀一切 提交于 2019-12-04 18:06:28
问题 I am trying to display numbers within a particular table with ordinal suffixes. The table always shows three numbers which come from an XML file. The numbers show ranks, so for example they may be 6th, 120th, 131st. The output is a table that would look like this: <table> <tr> <td class='ordinal'>6</td> <td class='ordinal'>120</td> <td class='ordinal'>131</td> </tr> </table> I would ideally like to use javascript and I found a few very good solutions on stackoverflow, for example this one.

Converting String to Ordinal Value

雨燕双飞 提交于 2019-12-03 01:13:30
问题 I'm looking to compute the sum of the ordinal values of all the characters of the full name string, and will output this sum. here is what I have so far. a = input('Enter your first name: ') b = input('Enter your last name: ') c = print("your full name is:", a, b) print(ord(a)) so for example if you put Mary for the first name and Joe for the last name the full name would be Mary Joe and the ordinal value would be 727. 回答1: If you only concatenate a and b you will get 695 : print(sum(ord(i)

Converting String to Ordinal Value

放肆的年华 提交于 2019-12-02 13:37:05
I'm looking to compute the sum of the ordinal values of all the characters of the full name string, and will output this sum. here is what I have so far. a = input('Enter your first name: ') b = input('Enter your last name: ') c = print("your full name is:", a, b) print(ord(a)) so for example if you put Mary for the first name and Joe for the last name the full name would be Mary Joe and the ordinal value would be 727. If you only concatenate a and b you will get 695 : print(sum(ord(i) for i in a+b)) # 695 But, it seems you also need a space between the first and last name: print(sum(ord(i)