0
I’m trying to work with arrays but I’m having difficulty accessing the items or they see grouped or they generate several arrays, which I can’t access.
CONTROLLER
$listaDescontos = $dados['listTabelaDesconto'];
foreach($listaDescontos as $key => $value){
$listDesc = $value['usu_tabdsc'];
$dados['listFPG'] = (new Step3Model)->getAllFormaPagamentoLocal($_SESSION['filial'],$listDesc);
$list = $dados['listFPG'];
foreach($list as $keyList ){
$teste = $keyList;
print_r( $teste);
//$dados['listFormaPgto'] = $valueList;
}
}
VIEW
foreach($listFormaPgto as $item) {
if(isset($_POST['formaPgto']) && $_POST['formaPgto'] == $item['codfpg']){
$selected = 'selected';
} else if(isset($currentPedido) && $currentPedido['codfpg'] == $item['codfpg']){
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="'.$item['codfpg'].'" '.$selected.'>'.$item['desfpg'].'</option>';
}
RESULTING ARRAY
Array ( [codfpg] => 9 [0] => 9 [desfpg] => VALE OF [1] => VALE OF [usu_moefpg] => AU [2] => AU ) Array ( [codfpg] => 1 [0] => 1 [desfpg] => Cobranca Bancaria [1] => Cobranca Bancaria [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 3 [0] => 3 [desfpg] => Deposito em Conta [1] => Deposito em Conta [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 5 [0] => 5 [desfpg] => Dinheiro [1] => Dinheiro [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 6 [0] => 6 [desfpg] => VALE RS [1] => VALE RS [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 7 [0] => 7 [desfpg] => CHEQUE [1] => CHEQUE [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 10 [0] => 10 [desfpg] => Cartao Debito [1] => Cartao Debito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 11 [0] => 11 [desfpg] => Cartao Credito [1] => Cartao Credito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 99 [0] => 99 [desfpg] => Crediario [1] => Crediario [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 1 [0] => 1 [desfpg] => Cobranca Bancaria [1] => Cobranca Bancaria [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 3 [0] => 3 [desfpg] => Deposito em Conta [1] => Deposito em Conta [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 5 [0] => 5 [desfpg] => Dinheiro [1] => Dinheiro [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 6 [0] => 6 [desfpg] => VALE RS [1] => VALE RS [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 7 [0] => 7 [desfpg] => CHEQUE [1] => CHEQUE [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 10 [0] => 10 [desfpg] => Cartao Debito [1] => Cartao Debito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 11 [0] => 11 [desfpg] => Cartao Credito [1] => Cartao Credito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 99 [0] => 99 [desfpg] => Crediario [1] => Crediario [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 1 [0] => 1 [desfpg] => Cobranca Bancaria [1] => Cobranca Bancaria [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 3 [0] => 3 [desfpg] => Deposito em Conta [1] => Deposito em Conta [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 5 [0] => 5 [desfpg] => Dinheiro [1] => Dinheiro [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 6 [0] => 6 [desfpg] => VALE RS [1] => VALE RS [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 7 [0] => 7 [desfpg] => CHEQUE [1] => CHEQUE [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 10 [0] => 10 [desfpg] => Cartao Debito [1] => Cartao Debito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 11 [0] => 11 [desfpg] => Cartao Credito [1] => Cartao Credito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 99 [0] => 99 [desfpg] => Crediario [1] => Crediario [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 1 [0] => 1 [desfpg] => Cobranca Bancaria [1] => Cobranca Bancaria [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 3 [0] => 3 [desfpg] => Deposito em Conta [1] => Deposito em Conta [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 5 [0] => 5 [desfpg] => Dinheiro [1] => Dinheiro [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 6 [0] => 6 [desfpg] => VALE RS [1] => VALE RS [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 7 [0] => 7 [desfpg] => CHEQUE [1] => CHEQUE [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 10 [0] => 10 [desfpg] => Cartao Debito [1] => Cartao Debito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 11 [0] => 11 [desfpg] => Cartao Credito [1] => Cartao Credito [usu_moefpg] => 01 [2] => 01 ) Array ( [codfpg] => 99 [0] => 99 [desfpg] => Crediario [1] => Crediario [usu_moefpg] => 01 [2] => 01 )
I need to get the information like desfpg, codfpg, usu_moefpg in variables but I’m not getting success proceeding this way. HELP!