Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $usuarios = ['nome1', 'nome2', 'nome3', 'nome4', 'nome5', 'nome6'];
- $maquinas = ['maquina1', 'maquina2', 'maquina3'];
- $array = [
- "usuarios" => $usuarios,
- "maquinas" => $maquinas
- ];
- $t = null;
- /**
- * PRECISO SABER QUAL DOS INDICES TEM MAIS VALUES
- * ASSIM POSSO FAZER O FOR PELO MAIOR VALOR
- */
- foreach ($array as $a) {
- $t[] = count($a);
- }
- $total = max($t);
- ?>
- <table class="table table-striped">
- <thead>
- <tr>
- <th>Usuário</th>
- <th>Maquina</th>
- </tr>
- </thead>
- <tbody>
- <?php
- for ($p = 0; $p <= $total; $p++) {
- echo "<tr>";
- echo (isset($array['usuarios'][$p])) ? "<td>{$array['usuarios'][$p]}</td>" : "<td></td>";
- echo (isset($array['maquinas'][$p])) ? "<td>{$array['maquinas'][$p]}</td>" : "<td></td>";
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment