pauker.at

Finnisch Deutsch Wörterbücher Übersetzungsforen

Zahl:   Liste   PHP code
<?
#
# numbers as text
# Zahlen als Text dargestellt
#
# (C) Stefan Zwischenbrugger
#
# Französische Zahlen fast fertig
# Deutsche Zahlen fehlen noch
#
if (!@$_ztools_number){
    
$_ztools_number 1;
    if (!@
$langu){
        
$langu="FR";
    }

    class 
ztool_number {

        var 
$fix_de=array();
        var 
$fix_fr=array();
        var 
$multi_fr=array();

    function 
__CONSTRUCT(){
            
#
            # Zahlen für Deutsch
            #
            
$this->fix_de=array(
            
0=>"null",
            
1=>"eins",
            
2=>"zwei",
            
3=>"drei",
            
4=>"vier",
            
5=>"f&uuml;nf",
            
6=>"sechs",
            
7=>"sieben",
            
8=>"acht",
            
9=>"neun",
            
10=>"zehn",
            
11=>"elf",
            
12=>"zw&ouml;lf",
            
13=>"dreizehn",
            
14=>"vierzehn",
            
15=>"f&uuml;nfzehn",
            
16=>"sechszehn",
            
17=>"siebzehn",
            
18=>"achtzehn",
            
19=>"neunzehn",
            
20=>"zwanzig",
            
21=>"einundzwanzig",
            
22=>"zweiundzwanzig",
            
23=>"dreiundzwanzig",
            
24=>"vierundzwanzig",
            
30=>"drei&szlig;ig",
            
31=>"einunddrei&szlig;ig",
            
32=>"zweiunddrei&szlig;ig",
            
33=>"dreiunddrei&szlig;ig",
            
40=>"vierzig",
            
50=>"f&uuml;nfzig",
            
60=>"sechzig",
            
70=>"siebzig",
            
71=>"einundsiebzig",
            
72=>"zweiundsiebzig",
            
73=>"dreiundsiebzig",
            
80=>"achtzig",
            
81=>"einundachtzig",
            
82=>"zweiundachtzig",
            
83=>"dreiundachtzig",
            
90=>"neunzig",
            
91=>"einundneunzig",
            
92=>"zweiundneunzig",
            
93=>"dreiundneunzig",
            
100=>"hundert",
            
101=>"hunderteins",
            
102=>"hundertzwei",
            
103=>"hundertdrei",
            
200=>"zweihundert",
            
300=>"dreihundert",
            
400=>"vierhundert",
            
500=>"f&uuml;nfhundert",
            
600=>"sechshundert",
            
700=>"siebenhundert",
            
800=>"achthundert",
            
900=>"neunhundert",
            
1000=>"tausend",
            
1001=>"tausendeins",
            
2000=>"zweitausend",
            
10000=>"zehntausend",
            
100000=>"hunderttausend",
            
1000000=>"eine Million" );
            
#
            # Zahlen für Französisch
            #
            
$this->fix_fr=array(
            
0=>"z&eacute;ro",
            
1=>"un",
            
2=>"deux",
            
3=>"trois",
            
4=>"quatre",
            
5=>"cinq",
            
6=>"six",
            
7=>"sept",
            
8=>"huit",
            
9=>"neuf",
            
10=>"dix",
            
11=>"onze",
            
12=>"douze",
            
13=>"treize",
            
14=>"quatorze",
            
15=>"quinze",
            
16=>"seize",
            
17=>"dix-sept",
            
18=>"dix-huit",
            
19=>"dix-neuf",
            
20=>"vingt",
            
21=>"vingt et un",
            
22=>"vingt-deux",
            
23=>"vingt-trois",
            
24=>"vingt-quatre",
            
30=>"trente",
            
31=>"trente et un",
            
32=>"trente-deux",
            
33=>"trente-trois",
            
40=>"quarante",
            
50=>"cinquante",
            
60=>"soixante",
            
70=>"soixante-dix",
            
71=>"soixante-onze",
            
72=>"soixante-douze",
            
73=>"soixante-treize",
            
80=>"quatre-vingt",
            
81=>"quatre-vingt un",
            
82=>"quatre-vingt-deux",
            
83=>"quatre-vingt-trois",
            
90=>"quatre-vingt-dix",
            
91=>"quatre-vingt-onze",
            
92=>"quatre-vingt-douze",
            
93=>"quatre-vingt-treize",
            
100=>"cent",
            
101=>"cent-un",
            
102=>"cent-deux",
            
103=>"cent-trois",
            
200=>"deux-cent",
            
300=>"trois-cent",
            
400=>"quatre-cent",
            
500=>"cinq-cent",
            
600=>"six-cent",
            
700=>"sept-cent",
            
800=>"huit-cent",
            
900=>"neuf-cent",
            
1000=>"mille",
            
1001=>"mille-un",
            
2000=>"deux-mille",
            
10000=>"dix-mille",
            
100000=>"cent-mille",
            
1000000=>"million" );

            
$this->multi_fr=array(0,1,2,3,4,5,6,7,8,9,10,
            
11,12,13,14,15,16,17,18,19,20,
            
30=>30,40=>40,50=>50,60=>60,80=>80,100=>100,1000=>1000,1000000=>1000000);

        }

        function 
number($p_zahl,$p_langu){

            if (
$p_langu=="FR"){
                
$return $this->number_fr($p_zahl,"");
                
$return str_replace("--","-",$return);
                
$return str_replace("--","-",$return);
                
$return str_replace(" -"," ",$return);
                while(
substr($return,0,1)=="-"){
                    
$return=substr($return,1);
                }
                return 
$return;
            }

        }

        function 
number_fr($p_zahl,$p_pre){

            if (
$p_zahl<0){
                
$p_pre "minus ";
                
$p_zahl*=-1;
            }

            
krsort($this->fix_fr);

            foreach(
$this->fix_fr as $zahl => $word){
                if (
$zahl==$p_zahl){
                    return 
$p_pre."-".$word;
                } elseif (
$zahl $p_zahl and $this->multi_fr[$zahl]){
                    
$multiplikator floor $p_zahl $zahl );
                    if (
$multiplikator>1){
                        
$p_middle $this->number_fr($multiplikator,"");
                    }
                    return 
$this->number_fr($p_zahl-($zahl*$multiplikator),$p_pre."-".$p_middle."-".$word);
                }
            }
            return 
"? number_fr($p_zahl,$p_pre)";


        }

        function 
number_fr_list(){

       
?><form>
       <table><tr><td valign=middle>
       Zahl:
       </td><td valign=middle>
       <input name=number value="<? echo @$_GET["number"?>">
       </td><td valign=middle>
       <input type=submit value="in Worten">
       </td><td valign=middle>
           &nbsp;&nbsp;<a href=?number=0>Liste</a>
       </td><td valign=middle>
           &nbsp;&nbsp;<a href=?phpcode=1>PHP code</a>
       </td></tr></table>
       </form><?
       
if (@$_GET["phpcode"]){
           echo 
"<div style='background:white'>";
           
highlight_file("/web/stefanz/ztools/ztool_number.inc");
           echo 
"</div>";
           return;
       }

       if (@
$_GET["number"]){
           echo 
$this->number($_GET["number"],"FR");
       } else {
           
?><table><?
           
foreach($this->fix_fr as $k => $v){
               
?><tr><td class="align_right"><? echo $k ?></td><td class="align_right"><?
               
echo $v ?></td><td class="align_right"><?
               
echo $this->fix_de[$k?></td><?
               
if ($k==70){ ?><td>in der Schweiz: septante</td><? }
               if (
$k==80){ ?><td>in der Schweiz: huitante, Belgien octante</td><? }
               if (
$k==90){ ?><td>in der Schweiz: nonante</td><? }
               
?></tr><?
           
}
           
?></table><?
       
}

        }

    }
    
$cl_number = new ztool_number();
}
?>
Ä
  <-- Eingabehilfe einblenden - klicken