Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $array = [
- "posicao" => [0],
- "nome" => ['nome1', 'nome2', 'nome3', 'nome4', 'nome5', 'nome6'],
- "variacao" => [10, 20]
- ];
- $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>Posição</th>
- <th>Nome</th>
- <th>Variação</th>
- </tr>
- </thead>
- <tbody>
- <?php
- for ($p = 0; $p <= $total; $p++) {
- echo "<tr>";
- echo (isset($array['posicao'][$p])) ? "<td>{$array['posicao'][$p]}</td>" : "<td></td>";
- echo (isset($array['nome'][$p])) ? "<td>{$array['nome'][$p]}</td>" : "<td></td>";
- echo (isset($array['variacao'][$p])) ? "<td>{$array['variacao'][$p]}</td>" : "<td></td>";
- echo "</tr>";
- }
- ?>
- </tbody>
- </table>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement