public function numberToHebrewNumerals($number, $show_thousands)
    {
        // Years (e.g. "5782") may be written without the thousands (e.g. just "782"),
        // but since there is no zero, the number 5000 must be written as "5 thousand"
        if ($show_thousands || $number % 1000 === 0) {
            $thousands = (int)($number / 1000);
        } else {
            $thousands = 0;
        }
        $number = $number % 1000;

        $hebrew = $this->numberToNumerals($number, self::$HEBREW_NUMERALS_UTF8);

        // Two bytes per UTF8 character
        if (strlen($hebrew) === 2) {
            // Append a geresh after single-digit
            $hebrew .= self::GERESH;
        } elseif (strlen($hebrew) > 2) {
            // Some letters have a "final" form, when used at the end of a word.
            $hebrew = substr($hebrew, 0, -2) . strtr(substr($hebrew, -2), self::$FINAL_FORMS_UTF8);
            // Insert a gershayim before the final letter
            $hebrew = substr_replace($hebrew, self::GERSHAYIM, -2, 0);
        }

        if ($thousands) {
            if ($hebrew) {
                $hebrew = $this->numberToHebrewNumerals($thousands, $show_thousands) . $hebrew;
            } else {
                $hebrew = $this->numberToHebrewNumerals($thousands, $show_thousands) . ' ' . self::ALAFIM;
            }
        }

        return $hebrew;
    }
public function numberToHebrewNumerals($number, $show_thousands)
    {
        // Years (e.g. "5782") may be written without the thousands (e.g. just "782"),
        // but since there is no zero, the number 5000 must be written as "5 thousand"
        if ($show_thousands || $number % 1000 === 0) {
            $thousands = (int)($number / 1000);
        } else {
            $thousands = 0;
        }
        $number = $number % 1000;

        $hebrew = $this->numberToNumerals($number, self::$HEBREW_NUMERALS_UTF8);

        // Two bytes per UTF8 character
        if (strlen($hebrew) === 2) {
            // Append a geresh after single-digit
            $hebrew .= self::GERESH;
        } elseif (strlen($hebrew) > 2) {
            // Some letters have a "final" form, when used at the end of a word.
            $hebrew = substr($hebrew, 0, -2) . strtr(substr($hebrew, -2), self::$FINAL_FORMS_UTF8);
            // Insert a gershayim before the final letter
            $hebrew = substr_replace($hebrew, self::GERSHAYIM, -2, 0);
        }

        if ($thousands) {
            if ($hebrew) {
                $hebrew = $this->numberToHebrewNumerals($thousands, $show_thousands) . $hebrew;
            } else {
                $hebrew = $this->numberToHebrewNumerals($thousands, $show_thousands) . ' ' . self::ALAFIM;
            }
        }

        return $hebrew;
    }
public function numberToHebrewNumerals ( $ number , $ show_thousands ) { // Years (e.g. "5782") may be written without the thousands (e.g. just "782"), // but since there is no zero, the number 5000 must be written as "5 thousand" if ( $ show_thousands || $ number % 1000 === 0 ) { $ thousands = ( int ) ( $ number / 1000 ) ; } else { $ thousands = 0 ; } $ number = $ number % 1000 ; $ hebrew = $ this -> numberToNumerals ( $ number , self :: $ HEBREW_NUMERALS_UTF8 ) ; // Two bytes per UTF8 character if ( strlen ( $ hebrew ) === 2 ) { // Append a geresh after single-digit $ hebrew .= self :: GERESH ; } elseif ( strlen ( $ hebrew ) > 2 ) { // Some letters have a "final" form, when used at the end of a word. $ hebrew = substr ( $ hebrew , 0 , - 2 ) . strtr ( substr ( $ hebrew , - 2 ) , self :: $ FINAL_FORMS_UTF8 ) ; // Insert a gershayim before the final letter $ hebrew = substr_replace ( $ hebrew , self :: GERSHAYIM , - 2 , 0 ) ; } if ( $ thousands ) { if ( $ hebrew ) { $ hebrew = $ this -> numberToHebrewNumerals ( $ thousands , $ show_thousands ) . $ hebrew ; } else { $ hebrew = $ this -> numberToHebrewNumerals ( $ thousands , $ show_thousands ) . ' ' . self :: ALAFIM ; } } return $ hebrew ; }
Convert a number into Hebrew numerals using UTF8.

@param int  $number
@param bool $show_thousands

@return string
Convert a number into Hebrew numerals using UTF8 .