I have a foreach cycle to go through all the states and I need that all the states are stored in the variable but only the last state is being stored, how can I do so that it does not substitute the value for each iteration? here the controller code
foreach ($estados as $estado) {
$datos['codigo_estado'] = $estado['codigo_estado'];
$porEstados = $this->modelo_base_m->cuentaPorEstados($datos);
}
and here the code of the model
public function cuentaPorEstados($datos){
extract($datos);
$cadena = "(fecha_registro >= '$fecha_inicio' AND fecha_registro <= '$fecha_fin') AND (edad >=0 AND edad <=120)";
$this->db->select('*');
$this->db->from('dean_eapg.v_evaluaciones');
$this->db->where($cadena);
$this->db->where('codigo_estado',$codigo_estado);
$rs = $this->db->get();
$resultado = $rs->result_array();
return $resultado;
}