0
only here to settle certain things.
I’m breaking my head to make this loop but I haven’t got it yet.
How do I put the highlight in this array() and only 1 of these photos will be marked with the value 1.
$fotos = $this->input->post('fotos[]');
$destaque = $this->input->post('destaque[]');
$foto = array();
foreach ( $fotos as $item => $value){
array_push($foto, array(
'idFoto' => $id,
'img' => $value
'destaque' => $
));
}
The result I hope is something like this:
array(
array(idFoto => 1,
img => 1.jpg,
destaque => Null),
array(idFoto => 2,
img = 2.jpg,
destaque => 1), //Nesse caso o radio foi checado
array(idFoto => 3,
img => 3.jpg,
destaque => Null)
);
In the case of html I input several photos and one of them I select as highlight.
The highlight is a array also? What about the variable
$destaque
? is the index of some element of the array$fotos
?– KaduAmaral
$featured comes from a radio and if checked records a value 1 but is only one of the photos will contain the value 1. in case I forgot to put the bracket there...but the bracket is not the issue...
– Jaciel Placidino
In the case highlight is the photo ID or the array index? Can you give an example of the final result you expect?
– Papa Charlie
@Jacielplacidino each photo has a radio button?
– KaduAmaral
To make it easier, you can make one
var_dump
of the variables$fotos
and$destaque
and/or also post the HTML for the form, placing this information in the body of the question by clicking on edit just below your question.– KaduAmaral
@Kaduamaral yes for each photo has a radio highlight[].
– Jaciel Placidino
@Jacielplacidino, try so on each radio put the
value
with a number of0
incrementing one each photo,0,1,2,3,...
and there in the loop put like this'destaque' => ($destaque == $item ? 1 : 0)
.– KaduAmaral