Word of the Day
Showing posts with label hebrew. Show all posts
Showing posts with label hebrew. Show all posts

Monday, April 7, 2008

GemCoverter converts Arabic numbers into Hebrew Numerals

So, I hope this PHP script is a great relief for all those who have difficulty switching between Arabic numbers and Hebrew Numerals.

Please add "< ? p,h,p" before the first IF clause.

/*Copyright: Sparnai; Date 2008-04-08*/

[noparse]
if($_POST["in"] == null){
print "Please enter a number.";
}elseif(preg_match("/^[1-9][0-9]{0,2}$/",$_POST["in"])){
$in = $_POST["in"];
}else{
die("Wrong input!");
}



if($in <= 999 and $in >= 900){$_900='תתק';}
elseif($in <= 899 and $in >= 800){$_900='תת';}
elseif($in <= 799 and $in >= 700){$_900='תש';}
elseif($in <= 699 and $in >= 600){$_900='תר';}
elseif($in <= 599 and $in >= 500){$_900='תק';}
elseif($in <= 499 and $in >= 400){$_900='ת';}
elseif($in <= 399 and $in >= 300){$_900='ש';}
elseif($in <= 299 and $in >= 200){$_900='ר';}
elseif($in <= 199 and $in >= 100){$_900='ק';}
else{$_900='';}



$_in099 = substr($in,-2);

if($_in099 <= 99 and $_in099 >= 90){$_090 = 'צ';}
elseif($_in099 <= 89 and $_in099 >= 80){$_090 = 'פ';}
elseif($_in099 <= 79 and $_in099 >= 70){$_090 = 'ע';}
elseif($_in099 <= 69 and $_in099 >= 60){$_090 = 'ס';}
elseif($_in099 <= 59 and $_in099 >= 50){$_090 = 'נ';}
elseif($_in099 <= 49 and $_in099 >= 40){$_090 = 'מ';}
elseif($_in099 <= 39 and $_in099 >= 30){$_090 = 'ל';}
elseif($_in099 <= 29 and $_in099 >= 20){$_090 = 'כ';}
elseif($_in099 <= 19 and $_in099 >= 10){$_090 = 'י';}
else{$_090 = '';}



$_in009 = substr($in,-1);

if($_in009 == 9){$_009 = 'ט';}
elseif($_in009 == 8){$_009 = 'ח';}
elseif($_in009 == 7){$_009 = 'ז';}
elseif($_in009 == 6){$_009 = 'ו';}
elseif($_in009 == 5){$_009 = 'ה';}
elseif($_in009 == 4){$_009 = 'ד';}
elseif($_in009 == 3){$_009 = 'ג';}
elseif($_in009 == 2){$_009 = 'ב';}
elseif($_in009 == 1){$_009 = 'א';}
else{$_009 = '';}



if($_in099 == 16){$_099 = 'טז';}
elseif($_in099 == 15){$_099 = 'טו';}
else {$_099 = $_090.$_009;}



$_999 = $_900.$_099;

if(strlen($_999) > 7){
$_999g = substr($_999,0,strlen($_999)-7).'״'.substr($_999,-7);}
else{
$_999g = $_999;}

if($in > 0){print 'The Hebrew numeral for '.number_format($in).' is:
'.$_999.'
'.$_999g;}
else{print "";}

?>[/noparse]

Sunday, April 6, 2008

Hebrew Numeral Converter

I have been having trouble converting numbers into Hebrew numerals. Finding nothing on the 'Net that does what I want to do, I created a Web application myself. The following is the PHP script. I will be using it to search Hebrew Bible by chapters and verses numbers.


$in = $_POST["in"];


if($in <= 999 and $in >= 900){$_900='ttq';}
elseif($in <= 899 and $in >= 800){$_900='tt';}
elseif($in <= 799 and $in >= 700){$_900='tx';}
elseif($in <= 699 and $in >= 600){$_900='tr';}
elseif($in <= 599 and $in >= 500){$_900='tq';}
elseif($in <= 499 and $in >= 400){$_900='t';}
elseif($in <= 399 and $in >= 300){$_900='x';}
elseif($in <= 299 and $in >= 200){$_900='r';}
elseif($in <= 199 and $in >= 100){$_900='q';}
else{$_900='';}



$_in099 = substr($in,-2);


if($_in099 <= 99 and $_in099 >= 90){$_090 = 'c';}
elseif($_in099 <= 89 and $_in099 >= 80){$_090 = 'p';}
elseif($_in099 <= 79 and $_in099 >= 70){$_090 = 'o';}
elseif($_in099 <= 69 and $_in099 >= 60){$_090 = 's';}
elseif($_in099 <= 59 and $_in099 >= 50){$_090 = 'n';}
elseif($_in099 <= 49 and $_in099 >= 40){$_090 = 'm';}
elseif($_in099 <= 39 and $_in099 >= 30){$_090 = 'l';}
elseif($_in099 <= 29 and $_in099 >= 20){$_090 = 'k';}
elseif($_in099 <= 19 and $_in099 >= 10){$_090 = 'i';}
else{$_090 = '';}

$_in009 = substr($in,-1);

if($_in009 == 9){$_009 = 'w';}
elseif($_in009 == 8){$_009 = 'h';}
elseif($_in009 == 7){$_009 = 'z';}
elseif($_in009 == 6){$_009 = 'v';}
elseif($_in009 == 5){$_009 = 'e';}
elseif($_in009 == 4){$_009 = 'd';}
elseif($_in009 == 3){$_009 = 'g';}
elseif($_in009 == 2){$_009 = 'b';}
elseif($_in009 == 1){$_009 = 'a';}
else{$_009 = '';}



if($_in099 == 15){$_099 = 'wv';}
elseif($_in099 == 16){$_099 = 'wz';}
else {$_099 = $_090.$_009;}

$_999 = $_900.$_099;

if(strlen($_999) > 1){
$_999g = substr($_999,0,strrpos($_999,substr($_999,-1))).'״'.substr($_999,-1);}
else{
$_999g = $_999;}

print $_999;

print '
';

print $_999g;

?>