Läuft problemlos:
PHP-Code:
$roem = "IV";
echo "Roemisch: " . $roem .
"<br>Arabisch: " . umwandlung_von_roemisch($roem);
function umwandlung_von_roemisch($roem_zahl)
{
$wert = 0;
if($roem_zahl == "I")
{
$wert = 1;
}
else if($roem_zahl == "II")
{
$wert = 2;
}
else if($roem_zahl == "III")
{
$wert = 3;
}
else if($roem_zahl == "IV")
{
$wert = 4;
}
else if($roem_zahl == "V")
{
$wert = 5;
}
else if($roem_zahl == "VI")
{
$wert = 6;
}
else if($roem_zahl == "VII")
{
$wert = 7;
}
else if($roem_zahl == "VIII")
{
$wert = 8;
}
else if($roem_zahl == "IX")
{
$wert = 9;
}
else if($roem_zahl == "X")
{
$wert = 10;
}
else if($roem_zahl == "XI")
{
$wert = 11;
}
else if($roem_zahl == "XII")
{
$wert = 12;
}
else if($roem_zahl == "XIII")
{
$wert = 13;
}
else if($roem_zahl == "XIV")
{
$wert = 14;
}
else if($roem_zahl == "XV")
{
$wert = 15;
}
else if($roem_zahl == "XVI")
{
$wert = 16;
}
else if($roem_zahl == "XVII")
{
$wert = 17;
}
else if($roem_zahl == "XVIII")
{
$wert = 18;
}
else if($roem_zahl == "XIX")
{
$wert = 19;
}
else if($roem_zahl == "XX")
{
$wert = 20;
}
return $wert;
}
Ausgabe:
Roemisch: IV
Arabisch: 4