0

I have a foreach which basicaly lists clients withe their username , password and package. now i have a forach running perfect BUT it keeps showing some of the users 3 time for some reason , the data file where its getting all the info does not have the client 3 times. So for some reason foreach echo is showing the same value or user 3 times and then goes on. and its only some users not all. (there are NO duplicates in the data source) pls help :)

Code :

foreach ($info->accountswithinfo->account as $realminfo):

$uncapped=$realminfo->isuncapped;

if ($uncapped=='False')
{
    $username=$realminfo->username; 
    $password=$realminfo->password;
    $packagename=$realminfo->{'package-name'};

    $for=$realminfo->cap;

    $cap=Round(("$for") / (1024 * 1024 * 1024), 2);
}
?>
<tr>
    <?php
    echo '<td class="blockcontentwhite sessionicon">',
         '<td class="blockcontentwhite center">' . ("$username") . '</td>',
         '<td class="blockcontentwhite center">' . ("$password") . '</td>',
         '<td class="blockcontentwhite center">' . ("$cap GB") . '</td>',
         '<td class="blockcontentwhite center">' . ("$packagename") . '</td>';
    endforeach;
    ?>
4

2 に答える 2

1

ループの反復ごとに、ユーザー名、パスワード、およびその他の情報を表示しています。ただし、変更するのはユーザー名、パスワード、およびその他の情報のみです$uncapped=='False'

これ$uncapped以外の値を指定'False'すると、ユーザー名、パスワード、およびその他の情報が新しい値に設定されない場合があります。ループは、ループの前の反復で格納された値を出力します (最後の時間はいつでも$uncapped=='False')。

この問題の可能な解決策は、値の割り当てと出力を同じ if 条件でラップすることです。

于 2013-03-30T05:51:18.743 に答える