2
I have the following array()
:
Array
(
[valor] => Array
(
[0] => 433.36
[1] => 433.36
[2] => 433.36
[3] => 433.36
[4] => 433.36
[5] => 433.36
[6] => 433.36
[7] => 433.36
[8] => 433.36
[9] => 433.36
[10] => 433.36
[11] => 433.36
)
[data] => Array
(
[0] => 2015-10-21
[1] => 2015-10-21
[2] => 2015-10-21
[3] => 2015-10-21
[4] => 2015-10-21
[5] => 2015-10-21
[6] => 2015-10-21
[7] => 2015-10-21
[8] => 2015-10-21
[9] => 2015-10-21
[10] => 2015-10-21
[11] => 2015-10-21
)
[detalhes] => Array
(
[0] =>
[1] =>
[2] =>
[3] =>
[4] =>
[5] =>
[6] =>
[7] =>
[8] =>
[9] =>
[10] =>
[11] =>
)
)
But I need the return of this array to come in the following format:
Array
(
[0] => Array
(
[campo1] => campo1
[campo2] => campo2
[campo3] => campo3
)
[1] => Array
(
[campo1] => campo1
[campo2] => campo2
[campo3] => campo3
)
)
Form:
<form class="form-inline" method="post" action="<?php echo current_url(); ?>/adicionar">
<fieldset>
<div class="span12" style="height:35px;">
<div class="span3" style="text-align:right">
<strong>Registro</strong>
</div>
<div class="span9">
<? echo $lista_funcionario[0]->razaosocial; ?>
</div>
</div>
<div class="span12" style="height:35px;">
<div class="span3" style="text-align:right">
<strong>Base de Cáculo</strong>
</div>
<div class="span9">
<? if(empty($this->input->post('base_calculo'))) echo "MANUAL"; else echo $this->input->post('base_calculo'); ?>
</div>
</div>
<?
foreach($lista_funcionario as $valor){
/* Verificando se o tipo de parametro é vale */
if($this->uri->segment(3)=="840"){
$base_calculo = str_replace("%", "", $this->input->post('base_calculo'));
$valor_adiantamento = $valor->salario * $base_calculo / 100;
}
?>
<div class="span12" style="height:35px;">
<div class="span3" style="text-align:right">
<strong><? echo $valor->nome; ?></strong>
</div>
<div class="span1">
<input id="campo_valor[]" class="span12" type="text" name="campo_valor[]" value="<? if(!empty($this->input->post('valor')) and $this->input->post('valor')!=$valor_adiantamento){ echo $this->input->post('valor'); } elseif(!empty($valor_adiantamento)){ echo $valor_adiantamento; } ?>" placeholder="0.00" />
</div>
<div class="span2">
<input id="campo_data[]" class="span12" type="date" name="campo_data[]" value="<? if(!empty($this->input->post('data'))){ echo $this->input->post('data'); } ?>" />
</div>
<div class="span6">
<input id="campo_detalhes[]" class="span10" type="text" name="campo_detalhes[]" placeholder="Detalhes do Provento" />
</div>
</div>
<? } ?>
<div class="line" style="padding: 1%; margin-left: 0">
<div class="span6 offset3" style="text-align: center">
<button class="btn btn-success" id="btnContinuar"><i class="icon-plus icon-white"></i> Adicionar</button>
<a href="<?php echo base_url() ?>parametro" class="btn"><i class="icon-arrow-left"></i> Voltar</a>
</div>
</div>
</fieldset>
</form>
Update: Following the idea of the posted answer, was this way:
Array
(
[0] => Array
(
[campo] => Array
(
[0] => Array
(
[valor] => 433.36
[data] => 2015-10-21
[detalhes] =>
)
I would like to know how do I access this data so that I can insert them into the database in this way?
Not as the final array should be, you could put the keys and expected values
– rray
It is generated through print_r()
– Sr. André Baill