Converts number to its ordinal English form.

This method converts 13 to 13th, 2 to 2nd ...

@param    int $number Number to get its ordinal value

@return string Ordinal representation of given string.
514703
public static function ordinalize($number)
    {
        static::init();

        if (\in_array($number % 100, range(11, 13), true)) {
            return $number . static::$ordinals['default'];
        }

        switch ($number % 10) {
            case 1:
                return $number . static::$ordinals['first'];
            case 2:
                return $number . static::$ordinals['second'];
            case 3:
                return $number . static::$ordinals['third'];
            default:
                return $number . static::$ordinals['default'];
        }
    }
983653
public function toTheN($number)
    {
        for ($i = 1; $i <= $number; $i++) {
            $this->multiply($this->number);
        }

        return $this;
    }
1291666
public static function getWord($number)
    {
        $hyphen      = '-';
        $conjunction = ' and ';
        $separator   = ', ';
        $negative    = 'negative ';
        $decimal     = ' point ';
        $dictionary  = array(
            0                   => 'zero',
            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                  => 'fourty',
            50                  => 'fifty',
            60                  => 'sixty',
            70                  => 'seventy',
            80                  => 'eighty',
            90                  => 'ninety',
            100                 => 'hundred',
            1000                => 'thousand',
            1000000             => 'million',
            1000000000          => 'billion',
            1000000000000       => 'trillion',
            1000000000000000    => 'quadrillion',
            1000000000000000000 => 'quintillion'
        );

        if (!is_numeric($number)) {
            return false;
        }

        if (($number >= 0 && (int) $number < 0) || (int) $number < 0 - PHP_INT_MAX) {
            // overflow
            trigger_error(
                'convert_number_to_words only accepts numbers between -' . PHP_INT_MAX . ' and ' . PHP_INT_MAX,
                E_USER_WARNING
            );
            return false;
        }

        if ($number < 0) {
            return $negative . convert_number_to_words(abs($number));
        }

        $string = $fraction = null;

        if (strpos($number, '.') !== false) {
            list($number, $fraction) = explode('.', $number);
        }

        switch (true) {
            case $number < 21:
                $string = $dictionary[$number];
                break;
            case $number < 100:
                $tens     = ((int) ($number / 10)) * 10;
                $units    = $number % 10;
                $string = $dictionary[$tens];
                if ($units) {
                    $string .= $hyphen . $dictionary[$units];
                }
                break;
            case $number < 1000:
                $hundreds    = $number / 100;
                $remainder = $number % 100;
                $string = $dictionary[$hundreds] . ' ' . $dictionary[100];
                if ($remainder) {
                    $string .= $conjunction . convert_number_to_words($remainder);
                }
                break;
            default:
                $baseUnit = pow(1000, floor(log($number, 1000)));
                $numBaseUnits = (int) ($number / $baseUnit);
                $remainder = $number % $baseUnit;
                $string = convert_number_to_words($numBaseUnits) . ' ' . $dictionary[$baseUnit];
                if ($remainder) {
                    $string .= $remainder < 100 ? $conjunction : $separator;
                    $string .= convert_number_to_words($remainder);
                }
                break;
        }

        if (null !== $fraction && is_numeric($fraction)) {
            $string .= $decimal;
            $words = array();
            foreach (str_split((string) $fraction) as $number) {
                $words[] = $dictionary[$number];
            }
            $string .= implode(' ', $words);
        }

        return $string;
    }
1355555
public static function int_to_letter($number) {
        $alphabet = [
                '1' => 'A',
                '2' => 'B',
                '3' => 'C',
                '4' => 'D',
                '5' => 'E',
                '6' => 'F',
                '7' => 'G',
                '8' => 'H',
                '9' => 'I',
                '10' => 'J',
                '11' => 'K',
                '12' => 'L',
                '13' => 'M',
                '14' => 'N',
                '15' => 'O',
                '16' => 'P',
                '17' => 'Q',
                '18' => 'R',
                '19' => 'S',
                '20' => 'T',
                '21' => 'U',
                '22' => 'V',
                '23' => 'W',
                '24' => 'X',
                '25' => 'Y',
                '26' => 'Z'
        ];
        if (!is_integer($number) || $number < 1 || $number > count($alphabet)) {
            throw new coding_exception('Only integers between 1 and 26 can be converted to letters.', $number);
        }
        return $alphabet[$number];
    }
647292
public static function format($number, $format=Formatter::PHONE_E164) {
        $formattedNumber = '';
        $regex = "/[^0-9]/";
        $number = preg_replace($regex, "", $number);

        if(strlen($number) > 13)
            throw new \Exception('Unsupported Format for number '.$number);

        if(strlen($number) >10)
            $countryCode = "";
        else
            $countryCode = "91";
        $formattedNumber = "+$countryCode$number";
        return $formattedNumber;
    }
151402
public function monthInRoman($number)
    {
        $number = intval($number);
        $romanNumbers = array(
                1  => 'I',
                2  => 'II',
                3  => 'III',
                4  => 'IV',
                5  => 'V',
                6  => 'VI',
                7  => 'VII',
                8  => 'VIII',
                9  => 'IX',
                10 => 'X',
                11 => 'XI',
                12 => 'XII');
        if ($number >= 0 && $number <= 12) {
            return $romanNumbers[$number];
        } else {
            return $number;
        }
    }
558391
protected function toWords($number, $power = 0)
    {
        $return = '';

        if ($number < 0) {
            $return = $this->minus . ' ';
            $number = (int) abs($number);
        }

        if ($number == 0 || $number == '') {
            return $this->wordSeparator . self::$digits[0];
        }

        $gt2000 = $number > 2000;

        if (strlen($number) > 3) {
            $maxp = strlen($number) - 1;
            $curp = $maxp;
            for ($p = $maxp; $p > 0; --$p) { // power
                if (isset(self::$exponent[$p])) {
                    // send substr from $curp to $p
                    $snum = substr($number, $maxp - $curp, $curp - $p + 1);
                    $snum = preg_replace('/^0+/', '', $snum);

                    if ($snum !== '') {
                        $return .= $this->toWords($snum, $p);

                        if ($gt2000) {
                            $return .= $this->thousandSeparator;
                        }
                    }
                    $curp = $p - 1;
                    continue;
                }
            }

            $number = substr($number, $maxp - $curp, $curp - $p + 1);

            if ($number == 0) {
                return rtrim($return, $this->thousandSeparator);
            }
        }

        $d = $number % 10;
        $t = (int) ($number / 10) % 10;
        $h = (int) ($number / 100) % 10;

        if ($h) {
            $return .= $this->wordSeparator . self::$digits[$h] . $this->wordSeparator . 'száz';
        }

        // ten, twenty etc.
        switch ($t) {
            case 9:
            case 5:
                $return .= $this->wordSeparator . self::$digits[$t] . 'ven';
                break;
            case 8:
            case 6:
                $return .= $this->wordSeparator . self::$digits[$t] . 'van';
                break;
            case 7:
                $return .= $this->wordSeparator . 'hetven';
                break;
            case 3:
                $return .= $this->wordSeparator . 'harminc';
                break;
            case 4:
                $return .= $this->wordSeparator . 'negyven';
                break;
            case 2:
                switch ($d) {
                    case 0:
                        $return .= $this->wordSeparator . 'húsz';
                        break;
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        $return .= $this->wordSeparator . 'huszon';
                        break;
                }
                break;
            case 1:
                switch ($d) {
                    case 0:
                        $return .= $this->wordSeparator . 'tíz';
                        break;
                    case 1:
                    case 2:
                    case 3:
                    case 4:
                    case 5:
                    case 6:
                    case 7:
                    case 8:
                    case 9:
                        $return .= $this->wordSeparator . 'tizen';
                        break;
                }
                break;
        }

        if ($d > 0) {
            $return .= $this->wordSeparator . self::$digits[$d];
        }

        if ($power > 0) {
            if (isset(self::$exponent[$power])) {
                $lev = self::$exponent[$power];
            }

            if (!isset($lev) || !is_array($lev)) {
                return null;
            }

            $return .= $this->wordSeparator . $lev[0];
        }

        return $return;
    }
252644
public static function ordinal($number)
    {
        $test_c = abs($number) % 10;
        $ext = ((abs($number) % 100 < 21 && abs($number) % 100 > 4) ? 'th' : (($test_c < 4) ? ($test_c < 3) ? ($test_c < 2) ? ($test_c < 1) ? 'th' : 'st' : 'nd' : 'rd' : 'th'));

        return $number . $ext;
    }
986463
public function getNumberType(PhoneNumber $number)
    {
        $regionCode = $this->getRegionCodeForNumber($number);
        $metadata = $this->getMetadataForRegionOrCallingCode($number->getCountryCode(), $regionCode);
        if ($metadata === null) {
            return PhoneNumberType::UNKNOWN;
        }
        $nationalSignificantNumber = $this->getNationalSignificantNumber($number);
        return $this->getNumberTypeHelper($nationalSignificantNumber, $metadata);
    }
423007
public function transformToWords($number)
    {
        $units = $number % 10;
        $tens = (int) ($number / 10) % 10;
        $hundreds = (int) ($number / 100) % 10;
        $words = [];

        if ($hundreds > 0) {
            $words[] = $this->dictionary->getCorrespondingHundred($hundreds);
        }

        if ($tens !== 0 || $units !== 0) {
            $words[] = $this->getSubHundred($tens, $units);
        }

        return implode(' ', $words);
    }
22035
public static function numberToFromNativeLanguage($number, $options, $from = false) {
		if (!empty(self::$options['locale_override_class'])) {
			$locale_override_class = self::$options['locale_override_class'];
			if (!$from) {
				$number = $locale_override_class::amount($number . '', $options);
			} else {
				$number = $locale_override_class::readFloatval($number . '', $options);
			}
		}
		return $number;
	}
1165729
public function toRoman($number)
    {
        if (($number < self::MIN_VALUE) || ($number > self::MAX_VALUE)) {
            throw new \InvalidArgumentException();
        }

        $romanString = '';

        while ($number > 0) {
            foreach ($this->map as $key => $value) {
                if ($number >= $value) {
                    $romanString .= $key;
                    $number -= $value;
                    break;
                }
            }
        }

        return $romanString;
    }
1110104
private function normalizeNumber($number)
    {
        if (!is_numeric($number)) {
            throw new InvalidArgumentException('Number expected');
        }

        $number = floatval($number);

        if ($number < 0) {
            throw new InvalidArgumentException('The number expected was >= 0');
        }

        return max($number, 1);
    }
1044321
private static function getNum125($number) {
		/** @var int $result */
		/** @var int $n100 */
		$n100 = $number % 100;
		/** @var int $n100 */
		$n10 = $number % 10;
		if (($n100 > 10) && ($n100 < 20)) {
			$result = self::NUMBER_FORM_5;
		}
		else if ($n10 === 1) {
			$result = self::NUMBER_FORM_1;
		}
		else if (($n10 >= 2) && ($n10 <= 4)) {
			$result = self::NUMBER_FORM_2;
		}
		else {
			$result = self::NUMBER_FORM_5;
		}
		return $result;
	}
359393
private function twosComplement(string $number) : string
    {
        $xor = \str_repeat("\xff", \strlen($number));

        $number = $number ^ $xor;

        for ($i = \strlen($number) - 1; $i >= 0; $i--) {
            $byte = \ord($number[$i]);

            if (++$byte !== 256) {
                $number[$i] = \chr($byte);
                break;
            }

            $number[$i] = \chr(0);
        }

        return $number;
    }
899986
public static String ordinalize(int number){
        int modulo = number%100;
        if(modulo>=11 && modulo<=13)
            return number+"th";
        switch(number%10){
            case 1:
                return number+"st";
            case 2:
                return number+"nd";
            case 3:
                return number+"rd";
            default:
                return number+"th";
        }
    }
696411
public static function dec2big(string $number): string
    {
    	static::checkExtensionOrFail();

        $alphabet = static::NUMBERS;
        $number = trim((string)$number);

        if (strlen($number) == 0) {
            throw new Exception('Got empty number for dec2big, can not proceed');
        }

        $mod = (string)count($alphabet);
        $s = '';

        do {
            $x = bcdiv($number, $mod, 0);
            $left = bcmod($number, $mod);
            $char = $alphabet[$left];
            $s = $char . $s;

            $number = $x;
        } while ($x != '0');

        return $s;
    }