11
                            08月
                            2015
                        
                        
	39. 添加 th,st,nd 或者 rd 作为数字的后缀
Friday the 13th
| 
						 
							1
						 
						
							2
						 
						
							3
						 
						
							4
						 
						
							5
						 
						
							6
						 
						
							7
						 
					 | 
					
						function ordinal($cdnl){ 
							    $test_c = abs($cdnl) % 10; 
							    $ext = ((abs($cdnl) %100 < 21 && abs($cdnl) %100 > 4) ? 'th'
							            : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) 
							            ? 'th' : 'st' : 'nd' : 'rd' : 'th')); 
							    return $cdnl.$ext; 
							}
							 | 
				
语法:
| 
						 
							1
						 
						
							2
						 
						
							3
						 
						
							4
						 
					 | 
					
						<?php
							$number = 10;
							echo ordinal($number); //output is 10th
							?>
							 | 
				
特殊说明,本文版权归 ning个人博客 所有带原创标签请勿转载,转载请注明出处.