0
I’m trying to make a breadcrumb dynamic and need to make a loop to mount the link. At each loop, it needs to repeat the previous items, as in the example below the array and the output.
array( array( 'Bairro' , 'bairro' ) , array( 'Rua' , 'rua' ) )
<a href="bairro">Bairro</a>
<a href="bairro/rua">Rua</a>
What little I got was using unset to generate a new array. After this for to mount the repetition, i still need 2 more loops and reverse the order. A hell of a gambiarra.
foreach( $list as $i => $item ){
$newlist[] = $list;
unset( $list[$i] );
}
Just one question: does the breadcrumb label really need to occupy another position in your array? Wouldn’t it be better to be an associative array? Ex.:
array('item' => 'Label', 'bairro' => 'Bairro', 'rua' => 'Rua')
– Thomas
@Thomas, It would be better yes, but as I said, it is dynamic and with several sub items. If I could redo the array I would have no problem.
– Papa Charlie