Friday, 13 April 2018

WT-Slip19


19) Design a HTML page to accept a number and write a PHP script to display that number in wordse.g.  123 -à one two three 

<html>
<body>
<form method="POST"action="">
Please Enter Number:
<p><input type="text"name="number"value=""/>
<p><input type="submit"name="submit"value="submit">
</form>
</body>
</html>
<?php
if(!empty($_POST))
{
$numbers=$_POST['number'];
$str='';
$arr=array('0'=>'Zero','1'=>'One','2'=>'Two','3'=>'Three','4'=>'Four','5'=>'Five',
'6'=>'Six','7'=>'Seven','8'=>'Eight','9'=>'Nine');

$num=str_split($numbers);

foreach($num as $k=>$v)
{if(array_key_exists($v,$arr))

{ $str.=$arr[$v]."";  }  }

echo "Entered Number:-".$numbers;
echo "<br>".$str;
}
?>