Converting Word to
Digit
Write a
PHP program to convert word to digit.
1. Start Xampp server (Apache)
2. Goto virtual path folder (C:\xampp\htdocs)
3. Create convert.php file and type the program
4. Execute the program on your Web browser using by
this URL link
http://localhost/convert.php)
<html>
<body>
<?php
functionword_digit($word) {
$warr = explode(‘;’,$word);
$result = ‘’;
foreach($warr as $value){
switch(trim($value)){
case ‘zero’:
$result .= ‘0’;
break;
case ‘one’:
$result .= ‘1’;
break;
case ‘two’:
$result .= ‘2’;
break;
case ‘three’:
$result .= ‘3’;
break;
case ‘four’:
$result .= ‘4’;
break;
case ‘five’:
$result .= ‘5’;
break;
case ‘six’:
$result .= ‘6’;
break;
case ‘seven’:
$result .= ‘7’;
break;
case ‘eight’:
$result .= ‘8’;
break;
case ‘nine’:
$result .= ‘9’;
break;
}
}
return $result;
}
echoword_digit(“zero;three;five;six;eight;one”).”\n”;
echoword_digit(“seven;zero;one”).”\n”;
?>
</body>
</html>
035681
701
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.