$variants = array( '', //1 '', //2 '' //5 ); $amount = 15; echo $amount, ' ', RUtils::numeral()->choosePlural($amount, $variants); //Result: 15 echo RUtils::numeral()->getPlural(2, $variants); //Result: 2
echo RUtils::numeral()->sumString(1234, RUtils::MALE, $variants); //Result:
$numeral = RUtils::numeral(); echo $numeral->getInWordsInt(100); //Result: echo $numeral->getInWordsFloat(100.025); //Result: echo $numeral->getInWords(100.0); //Result:
echo RUtils::numeral()->getRubles(100.25); //Result:
\php_rutils\struct\TimeParams
, it is also possible to transfer them as an array $params = new TimeParams(); $params->date = null; // $params->format = ' d FY '; $params->monthInflected = true; echo RUtils::dt()->ruStrFTime($params); //Result: 22 2013
TimeParams
class.DateTime
class. $params = array( 'date' => '09-05-1945', 'format' => 'ld FY - ', 'monthInflected' => true, 'preposition' => true, ); echo RUtils::dt()->ruStrFTime($params); //Result: 9 1945 -
Dt::ruStrFTime
.$accuracy
parameter is responsible for the details of the information. $toTime = new \DateTime('05-06-1945'); echo RUtils::dt()->distanceOfTimeInWords($toTime); //Result: 24 976 $toTime = strtotime('05-06-1945'); $fromTime = null; //now $accuracy = 3; //, , echo RUtils::dt()->distanceOfTimeInWords($toTime, $fromTime, $accuracy); //Result: 24 976 , 11 , 21
$fromTime = '1988-01-01 11:40'; $toTime = '2088-01-01 12:35'; $accuracy = 3; //, , echo RUtils::dt()->distanceOfTimeInWords($toTime, $fromTime, $accuracy); //Result: 36 525 , 0 , 55
// echo RUtils::translit()->translify(' — '); //Result: Muha - eto malen'kaya ptichka // echo RUtils::translit()->detranslify("SCHuka"); //Result: // URL' echo RUtils::translit()->slugify(' — '); //Result: muha---eto-malenkaya-ptichka
$text = <<<TEXT ... . . ( " " № 45) Weather Forecast (r), - +-451F. TEXT; // echo RUtils::typo()->typography($text); /** * Result: * ... . . ( « » №45) Weather Forecast®, * — ±451°F. */ // "extended" echo RUtils::typo()->typography($text, TypoRules::$EXTENDED_RULES); /** * Result: * … . . ( « » №45) Weather Forecast®, * — ±451 °F. */ // echo RUtils::typo()->typography($text, array(TypoRules::DASHES, TypoRules::CLEAN_SPACES)); /** * Result: * ... . . ( " " № 45) Weather Forecast (r), * — +-451F. */
DateTime
class is also sometimes used. I decided that functions that work with dates should work with all three of these types. I also added the ability to specify a time zone for the transmitted time.Source: https://habr.com/ru/post/198544/
All Articles