Home | | Computer Application 12th Std | A PHP program to convert word to digit

Practical Experiments | Computer Applications - A PHP program to convert word to digit | 12th Computer Applications : Practical Experiments

Chapter: 12th Computer Applications : Practical Experiments

A PHP program to convert word to digit

Write a PHP program to convert word to digit.

Converting Word to Digit

 

AIM

Write a PHP program to convert word to digit.

 

Procedure

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>

 

OUTPUT

035681

701

Tags : Practical Experiments | Computer Applications , 12th Computer Applications : Practical Experiments
Study Material, Lecturing Notes, Assignment, Reference, Wiki description explanation, brief detail
12th Computer Applications : Practical Experiments : A PHP program to convert word to digit | Practical Experiments | Computer Applications


Privacy Policy, Terms and Conditions, DMCA Policy and Compliant

Copyright © 2018-2024 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.