192. PHP Program to find the positional value of the given digit in a number.
How does this program work?
- In this program you are going to learn about to find the positional value of the given digit in a number using PHP.
- First find the length of the given number and check it is numeric or not. After that print all positional value of digit in a number.
Here is the code
<html>
<head>
<title>PHP Program To find the positional value of the given digit in a number</title>
</head>
<body>
<form method="post">
<table border="0">
<tr>
<td> <input type="text" name="num" value="" placeholder="Enter number"/> </td>
</tr>
<tr>
<td> <input type="submit" name="submit" value="Submit"/> </td>
</tr>
</table>
</form>
<?php
if(isset($_POST['submit']))
{
$n = $_POST['num'];
//Makes a copy of the original number num
$n1 = $n;
echo "Given number : ".$n1."</br>";
echo "Digit | Position</br>";
for($i = 0, $length = strlen($n); $i < $length; $i++)
{
if(is_numeric($n[$i]))
echo $n[$i] . " | " . $i . "</br>";
}
return 0;
}
?>
</body>
</html>

