-4
Can anyone tell me what I did wrong in this job? can’t find the error.
public function inserir_fotos() {
$fotos = $this->input->post('fotos');
$data = array(
foreach ( $fotos as $item => $value){
array(
'idImovel' => $this->input->post('idImovel'),
'imgImovel' => $value
),
}
);
return $this->db->insert_batch('fotos', $data);
}
Beyond the array that is declared inside the foreach without assignment to any variable?
– Wallace Maxters
Typo, you put a
foreach
within an array, as far as I know, this does not exist in PHP. To add items to an array use$data[] =
orarray_push($data, ...)
.– Guilherme Nascimento
I suggest using sublime text with the Phplinter extension installed. Then you will see what is wrong before saving the code :)
– Wallace Maxters
Very fast guys on the trigger!!! Thanks even!!!!
– Jaciel Placidino
A hint next time you ask something, add the error message, in case I already edited, the error is:
syntax error, unexpected 'foreach' (T_FOREACH), expecting ')'
– Guilherme Nascimento