當前位置: 首頁>>代碼示例>>PHP>>正文


PHP text::fetch_ordinal_word方法代碼示例

本文整理匯總了PHP中text::fetch_ordinal_word方法的典型用法代碼示例。如果您正苦於以下問題:PHP text::fetch_ordinal_word方法的具體用法?PHP text::fetch_ordinal_word怎麽用?PHP text::fetch_ordinal_word使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在text的用法示例。


在下文中一共展示了text::fetch_ordinal_word方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: parse_ordinal_triplet

 public static function parse_ordinal_triplet($triplet, $order, $case, $gender, $subject_type, $noun, $with_declension, $custom_gender, $custom_subject_type, $custom_noun)
 {
     $numerals = self::$LIBTEXT_GLOBALS['numerals'];
     $str = array();
     assert(bccomp($triplet, '0') == 1);
     // Triplet must be nonzero
     $declined = false;
     $noun_variant = 0;
     // Varies from 1 to 3 (3rd uses data of 2nd with two exceptions)
     // Fetch number except hundreds (to check for exceptions between 11 and 19)
     $remainder = bcmod($triplet, '100');
     if (bccomp($remainder, '0') == 1) {
         if (bccomp('11', $remainder) != 1 && bccomp($remainder, '19') != 1) {
             // Whether to decline last triplet
             if ($with_declension) {
                 array_unshift($str, text::fetch_ordinal_word(intval($remainder), $case, $gender, $subject_type));
                 $declined = true;
             } else {
                 array_unshift($str, $numerals['cardinal']['exceptions'][$remainder][$case]);
                 // Define noun variant
                 $noun_variant = 3;
                 // Final variant
             }
         } else {
             $ones = bcmod($remainder, '10');
             if (bccomp($ones, '0') == 1) {
                 if ($with_declension) {
                     if ($order == 1) {
                         // Final word
                         array_unshift($str, text::fetch_ordinal_word(intval($ones), $case, $gender, $subject_type));
                     } else {
                         // Final trailing word expected further (like 'тысячный', 'миллионный' ...)
                         if (bccomp($triplet, '1') != 0) {
                             $number = $numerals['cardinal']['ones'][$ones][2];
                             // Use cardinal numerals in genitive case
                             if (bccomp($ones, '1') == 0) {
                                 array_unshift($str, $number[$gender]);
                                 // apply gender
                             } else {
                                 array_unshift($str, $number);
                             }
                             // use plain value
                         }
                     }
                     $declined = true;
                 } else {
                     $number = $numerals['cardinal']['ones'][$ones][1];
                     // Use case 1 only
                     // Exception: apply gender and subject type
                     if (bccomp($ones, '1') == 0) {
                         array_unshift($str, $number[$gender]);
                     } elseif (bccomp($ones, '2') == 0) {
                         array_unshift($str, $number[$gender]);
                     } elseif (bccomp($ones, '3') == 0) {
                         array_unshift($str, $number);
                     } elseif (bccomp($ones, '4') == 0) {
                         array_unshift($str, $number);
                     } else {
                         array_unshift($str, $number);
                     }
                     // for all others
                 }
                 // Define noun variant
                 if (bccomp($ones, '1') == 0) {
                     $noun_variant = 1;
                 } elseif (bccomp('2', $ones) != 1 && bccomp($ones, '4') != 1) {
                     $noun_variant = 2;
                 } else {
                     $noun_variant = 3;
                 }
                 // between 5 and 9
             }
             $tens = bcdiv($remainder, '10');
             if (bccomp($tens, '0') == 1) {
                 if ($with_declension) {
                     if ($order > 1) {
                         // Final trailing word expected further (like 'тысячный', 'миллионный' ...)
                         array_unshift($str, $numerals['cardinal']['tens'][bcmul($tens, '10')][2]);
                         // Use cardinal numerals in genitive case
                     } elseif (!$declined) {
                         // Final word
                         array_unshift($str, text::fetch_ordinal_word(intval(bcmul($tens, '10')), $case, $gender, $subject_type));
                     } else {
                         array_unshift($str, $numerals['cardinal']['tens'][bcmul($tens, '10')][1]);
                         // Define noun variant
                         if (empty($noun_variant)) {
                             $noun_variant = 3;
                         }
                         // Assume 3rd, may be overridden further
                     }
                     $declined = true;
                 } else {
                     array_unshift($str, $numerals['cardinal']['tens'][bcmul($tens, '10')][1]);
                     // Define noun variant
                     if (empty($noun_variant)) {
                         $noun_variant = 3;
                     }
                     // Assume 3rd, may be overridden further
                 }
             }
//.........這裏部分代碼省略.........
開發者ID:rigidus,項目名稱:SBIN-DIESEL,代碼行數:101,代碼來源:text.lib.php


注:本文中的text::fetch_ordinal_word方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。