I want to throw the variables that are null
to the end of the list. This is part of the composition of the view elements, they are blocks that can come empty, and I want to avoid having to compare variables and regroup. How can I redraw the display order of the elements on the page by throwing the empty end items?
In the example below I have the variables A, B, and C , in the normal case would make a foreach( $variavel_X as $linha )
and would have:
$variavel_A: nada aqui
$variavel_B: [ 'linha 1' , 'linha 2' , 'linha 3' ]
$variavel_C: [ 'linha 1' , 'linha 2' , 'linha 3' ]
What I need is to display as in the order below, where the empty variable appears last
$variavel_B: [ 'linha 1' , 'linha 2' , 'linha 3' ]
$variavel_C: [ 'linha 1' , 'linha 2' , 'linha 3' ]
$variavel_A: nada aqui
I thought of throwing variables in an array and reordering with arsort
, but the function will do the ascending (a-z) or decreasing (z-a) order, and that does not interest me much.