2
.tabela-grid{
margin: 0;
display: table;
width: 100%;
}
.tabela-grid *{
vertical-align: top;
text-align: center;
}
.tabela-grid img{
width: 100%;
display: inline-block;
}
.tabela-columm{
display: table-cell;
}
.tabela-columm:nth-child(even) .tabela-cell{
display: table;
}
.tabela-cell{
display: table-cell;
}
<div class="tabela-grid">
<div class="tabela-columm" style="background-color: red">
item1 </div>
<div class="tabela-columm" style="background-color: green">
<div class="tabela-cell">item2</div>
<div class="tabela-cell">item3</div>
</div>
<div class="tabela-columm" style="background-color: red">
item4 </div>
<div class="tabela-columm" style="background-color: green">
<div class="tabela-cell">item5</div>
<div class="tabela-cell">item6</div>
</div>
</div>
I have a array
which comes with the following content:
array (size=6)
0 =>
array (size=6)
'href' => string 'href'
'likes' => int 2
'img' => string 'href'
'text' => string 'comentario'
'width' => int 370
'height' => int 370
1 =>
array (size=6)
'href' => string 'href'
'likes' => int 12
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
2 =>
array (size=6)
'href' => string 'href'
'likes' => int 7
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
3 =>
array (size=6)
'href' => string 'href'
'likes' => int 1
'img' => string 'href'
'text' => string 'comentario'
'width' => int 370
'height' => int 370
4 =>
array (size=6)
'href' => string 'href'
'likes' => int 6
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
5 =>
array (size=6)
'href' => string 'href'
'likes' => int 5
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
I need to convert it to that format:
array (size=2)
0 =>
array (size=2)
0 =>
array (size=6)
'href' => string 'href'
'likes' => int 2
'img' => string 'href'
'text' => string 'comentario'
'width' => int 370
'height' => int 370
1 =>
array (size=2)
0 =>
array (size=6)
'href' => string 'href'
'likes' => int 12
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
1 =>
array (size=6)
'href' => string 'href'
'likes' => int 7
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
1 =>
array (size=2)
0 =>
array (size=6)
'href' => string 'href'
'likes' => int 2
'img' => string 'href'
'text' => string 'comentario'
'width' => int 370
'height' => int 370
1 =>
array (size=2)
0 =>
array (size=6)
'href' => string 'href'
'likes' => int 12
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
1 =>
array (size=6)
'href' => string 'href'
'likes' => int 7
'img' => string 'href'
'text' => string 'comentario'
'width' => int 175
'height' => int 175
is it possible to do it this way? I’m doing some tests so I simplified the data to make it easier, but I haven’t yet:
$entrada = array( 'item1', 'item2', 'item3', 'item4', 'item5', 'item6');
$saida= array(
0 => array( 0 => 'item1', 1 => array(0 => 'item2', 1 => 'item3') ),
1 => array( 0 => 'item4', 1 => array(0 => 'item5', 1 => 'item6') ),
);
Could you explain the because wishes to do this.. and if you have any logic in the process, or it would simply be to make the structure more complex?
– Israel Merljak
because of a table in the application frontend, I will put the image:
– Hebert Lima
I didn’t really understand why that, for me it only makes her more complex to work with
– Woton Sampaio
the table that will display this array was already like this
– Hebert Lima
Can you post the input array code? I’ll do an example here and I don’t want to reassemble all kkkk
– Woton Sampaio
Right.. It seems to me that there should be some logic in the structuring of this matrix, which you’re not making very clear. Without understanding the logic of this structure there is not much to do but only divide the array into arbitrary parts within another.
– Israel Merljak
the input is that of the variable
$entrada = array(“item1”,”item2”,”item3”, “item4”,”item5”,”item6”);
what is complicating is that the input is a simple array, if it is possible to popular the table with that same array helps a lot!– Hebert Lima
@Israelmerljak added the table structure!
– Hebert Lima
@Hebertdelima "item1", "item2" and "item3" have any relation?? If not, the answer from Woton is for you.. but I still think that if this array increases, it will become unviable this approach.
– Israel Merljak
@Israelmerljak I will test the answer of woton but I think it will work, it makes perfect sense his logic
– Hebert Lima