Here’s a simple Roman numerals chart created using PHP, HTML, and CSS. The PHP script dynamically generates a table of Roman numerals from 1 to 100.
Features:
- Uses PHP to generate Roman numerals.
- Styled with CSS for a clean look.
- Responsive design for better viewing on different devices.
roman-numbers.php
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Roman Numerals Chart</title> <link rel="stylesheet" href="styles.css"> </head> <body> <h1>Roman Numerals Chart (1-100)</h1> <table> <thead> <tr> <th>Number</th> <th>Roman Numeral</th> </tr> </thead> <tbody> <?php function numberToRoman($num) { $map = [ 100 => 'C', 90 => 'XC', 50 => 'L', 40 => 'XL', 10 => 'X', 9 => 'IX', 5 => 'V', 4 => 'IV', 1 => 'I' ]; $result = ''; foreach ($map as $value => $symbol) { while ($num >= $value) { $result .= $symbol; $num -= $value; } } return $result; } for ($i = 1; $i <= 100; $i++) { echo "<tr><td>{$i}</td><td>" . numberToRoman($i) . "</td></tr>"; } ?> </tbody> </table> <style> body { font-family: Arial, sans-serif; text-align: center; background-color: #f8f8f8; margin: 20px; } h1 { color: #333; } table { width: 50%; margin: auto; border-collapse: collapse; background: white; box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1); } th, td { border: 1px solid #ddd; padding: 10px; text-align: center; } th { background-color: #007BFF; color: white; } tr:nth-child(even) { background-color: #f2f2f2; } </style> </body> </html>