Skip to content

Instantly share code, notes, and snippets.

@LucianoCharlesdeSouza
Last active July 6, 2020 01:39
Show Gist options
  • Save LucianoCharlesdeSouza/c9d77bfb271e5e9be4f92a053e804f95 to your computer and use it in GitHub Desktop.
Save LucianoCharlesdeSouza/c9d77bfb271e5e9be4f92a053e804f95 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
</head>
<body>
<?php
echo '<table class="table table-striped table-bordered">';
echo '<thead>';
$titles = [
['title' => 'Nome'],
['title' => 'SobreNome'],
['title' => 'Idade'],
];
$texts = [
['nome' => 'nome 01', 'sobrenome' => 'sobrenome 01', 'idade' => 'idade 01'],
['nome' => 'nome 02', 'sobrenome' => 'sobrenome 02', 'idade' => 'idade 02'],
['nome' => 'nome 03', 'sobrenome' => 'sobrenome 03', 'idade' => 'idade 03'],
['nome' => 'nome 04', 'sobrenome' => 'sobrenome 04', 'idade' => 'idade 04'],
];
echo '<tr>';
foreach ($titles as $key => $title) {
if( $key % 2 === 0 && $key != 0 ){
echo '</tr>';
}
echo '<th scope="col">'.$title['title'].'</th>';
}
echo '</thead>';
echo '<tbody>';
foreach ($texts as $key => $text) {
echo '<tr>';
echo '<td scope="col">'.$text['nome'].'</td>';
echo '<td scope="col">'.$text['sobrenome'].'</td>';
echo '</tr>';
echo '<td scope="col">'.$text['idade'].'</td>';
}
echo '</tbody>';
echo '</table>';
?>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment