user2488832 user2488832 - 1 month ago 9
PHP Question

How to bold array elements in html table?

I'm trying to solve an exercise, but don't know how to go on. I need to make bold table's diagonal letters, like show on this picture:

enter image description here

Here's my code:

<?php
if (isset($_GET['word'])) {
$word = strtolower($_GET['word']);
$arr = str_split($word);}
else {
}
?>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Tabel.</title>
<style type="text/css">
td {
position:relative;
width: 20px;
height: 20px;
text-align: center;

}
}
table {border-collapse:collapse;}
</style>
</head>
<body>
<form action="tabel.php" method="get">
word: <input type="text" name="word"><input type="submit">
</form>
<?php
if (isset($arr)){
for ($i=0; $i < count($arr); $i++) {
foreach ($arr as $taht) { ?>
<table border="1" style="display:inline-table;">
<tr>
<td><?php echo $taht;?></td>
</tr>
</table>
</div><?php
}
?> <br> <?php
}
}
else {}

?>
</body>
</html>

Answer

As i said in my very first comment :

for($i .....)
  for($j ....)
     if($i == $j)    echo "<b>.....