While - Returns a record [closed]

0

I have a WebService that returns me some data like, extract, balance etc ...

But when I command to display the extract it returns me only the first record, not all. And keep repeating the 1st record.

<?php
session_start();
$cartao = $_SESSION['cartao'];
?>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />    
<?php

require_once 'vale-consulta.php';

try {

    $dados = array(
        'cd_grupo'        => '38',
        'de_login_usu'    => 'loginusuario',
        'de_senha_usu'    => 'senhapassword',
        'nu_cartao'       => $cartao,
        'fl_apenas_saldo' => 'N'
    );

    $vale = new ValeConsulta();
    $resposta = $vale->consultar( $dados );

    if ( $vale->tem_erro() ) {
        echo "Código: " . $resposta->erro->cod . "<br >\n";
        echo "MSG: " . $resposta->erro->msg . "<br >\n";
    } else {

        $nick         = $resposta->nome;
        $nome       = explode(" ", $nick);
        $saldo         = $resposta->vl_saldo;
        $ldata         = $resposta->lancamentos->lancto->dt_lancto;
        $ldesc      = $resposta->lancamentos->lancto->descricao;
        $lvalor       = $resposta->lancamentos->lancto->valor;
        $extrato    = $ldesc."</br>".$ldata."</br>".$lvalor."</br>";
    }

} catch( SoapFault $fault ) {
    echo "Erro: " . $fault->faultcode . " - " . $fault->faultstring;
}
?>

While

<?php
include("mostra.php")
//mostra extrato

$i = 1;
    while($i < 5) {
            echo $extrato; 
            $++;
        }
?>

Returning to me

Lucas SOBRE NOME MEU //MEU NOME COMPLETO
124                  //SALDO
KIDELICIA            //EXTRATO NOME DA EMPRESA
07/09/2016           //DATA EXTRATO
10,50 D              //VALOR NO DEBIDO

PDF HERE

    
asked by anonymous 08.09.2016 / 13:30

1 answer

1

You are retrieving an XML file by traversing the vector as below.

$resposta = $vale->consultar( $dados );
foreach($resposta->lancamentos->lancto as $info) {

    echo $info->dt_lancto . " - " . $info->descricao . " - " . info->valor;

}
    
08.09.2016 / 16:13