Create a PHP program that can input decimal then convert it binary, octal, hexadecimal using functions and arrays. Reminder: Do not use built-in functions for the conversion.
Create a PHP program that can input decimal then convert it binary, octal, hexadecimal using functions and arrays.
Reminder: Do not use built-in functions for the conversion.
MY CODE:
<!DOCTYPE html>
<html>
<body>
<title> Act </title>
<table>
<form action="Act.php" method="POST">
<td> Enter Decimal: </td>
<td><input type="text" name="amount" value="<?=isset($_POST['amount'])?$_POST['amount']:''?>"></td>
<td><input type="submit" value="Generate"></td>
</form>
<?php
if(isset($_POST['amount'])){
function dToB($n)
{
$amount;
$binaryNo;
$i = 0;
while($n > 0)
{
$binaryNo[$i] = $n % 2;
$n = (int) ($n / 2);
$i++;
}
for($j = $i - 1 ;$j >= 0; $j--)
echo $binaryNo[$j];
return $amount;
}
}
?>
<tr>
<td><b> Binary: </b></td>
<td> <input type="text" value="<?=isset($$amount)?$$amount: ''?>" readonly> </td>
</tr>
</table>
</html>
</body>
![Enter Decimal: 15
CONVERT
Binary
1111
Octal
17
Hexadecimal
F](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F73f859f1-ace8-4e34-98ec-1e3d67372cda%2Fa911011f-1d9a-431f-a0e2-c9eb1f3d44a4%2Fclcq35_processed.jpeg&w=3840&q=75)
![](/static/compass_v2/shared-icons/check-mark.png)
Step by step
Solved in 2 steps with 1 images
![Blurred answer](/static/compass_v2/solution-images/blurred-answer.jpg)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Computer Networking: A Top-Down Approach (7th Edi…](https://www.bartleby.com/isbn_cover_images/9780133594140/9780133594140_smallCoverImage.gif)
![Computer Organization and Design MIPS Edition, Fi…](https://www.bartleby.com/isbn_cover_images/9780124077263/9780124077263_smallCoverImage.gif)
![Network+ Guide to Networks (MindTap Course List)](https://www.bartleby.com/isbn_cover_images/9781337569330/9781337569330_smallCoverImage.gif)
![Concepts of Database Management](https://www.bartleby.com/isbn_cover_images/9781337093422/9781337093422_smallCoverImage.gif)
![Prelude to Programming](https://www.bartleby.com/isbn_cover_images/9780133750423/9780133750423_smallCoverImage.jpg)
![Sc Business Data Communications and Networking, T…](https://www.bartleby.com/isbn_cover_images/9781119368830/9781119368830_smallCoverImage.gif)