php - Line break in array

Asked

Viewed 686 times

-1

I’m wanting to skip line on a table, but I can’t find a logic to do it. I’ve tried the explode and failed.

<td><?=$teste['cod_refugo_teste'];?></td>
<td><?=$teste['qtd_refugo']; ?></td>

The code goes like this: inserir a descrição da imagem aqui

I want the refuse lines and quantity to be broken, but I can’t find a way to do it.

  • You are using the datatable?

  • Try it like this...;<td><?=$teste['cod_refugo_teste'];."</br>".$teste['qtd_refugo']; ?></td>

  • Post your table html structure. This is a table matter, not php

  • 1

    See: https://jsfiddle.net/mgd2b75p/6

  • Marcelo, the problem is that I will be skipping the cod_refugo_test and qtd_refuse arrays. I want you to skip the line to every scrap and every amount, you know?

  • When you say skip the line is to leave the fields all blank except the scrap and quantity ? I think it would be clearer if I set an example of how I expected it to look.

  • Without an example gets very confusing what you really need.

Show 2 more comments

2 answers

0

-1

Silvia, in this case it would be more interesting to see your complete code to understand what is inside the variable $teste.

The HTML tag for skipping lines is <tr></tr> which creates a new line. Each new line must be added a <tr></tr>.

If the variable values $teste are in an array, you can create a loop function, such as the for, as an example:

<?php

$valores = [
    'produto1',
    'quantidade1',
    'responsavel1',
    'data1',
    'produto1',
    'quantidade2',
    'responsavel2',
    'data2'
];

$html = "";

for ($n = 0 ; $n < count($valores) ; $n++) {
    if ($n % 3 == 0 || $n == 0)
        html += "<tr>";

    html += $valores[$n];

    if($n % 3 == 0 || $n == 0)
        html += "</tr>";
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.