-1

私はこのような配列を持っています:

Array
(
    [played] => 2
    [random] => 0
    [win] => 2
    [draws] => 11
    [passes] => 2
    [swaps] => 6
    [hpoints] => 0
    [lpoints] => -12
    [hmoves] => 11
    [lmoves] => 0
    [hpasses] => 1
    [lpasses] => 0
    [hswaps] => 3
    [lswaps] => 0
    [today] => 2013-04-04
    [tdpoints_temp] => -24
    [tdpoints] => -24
    [htdpoints] => 0
    [ltdpoints] => -12
)

次に、配列を次のように個別の値に取得します。

foreach($userStats as $singleStat){
    $played = $singleStat['played'];
    $random = $singleStat['random'];
    $win = $singleStat['win'];
    $draws = $singleStat['draws'];
    $passes = $singleStat['passes'];
    $swaps = $singleStat['swaps'];
    $hpoints = $singleStat['hpoints'];
    $lpoints = $singleStat['lpoints'];
    $hmoves = $singleStat['hmoves'];
    $lmoves = $singleStat['lmoves'];
    $hpasses = $singleStat['hpasses'];
    $lpasses = $singleStat['lpasses'];
    $hswaps = $singleStat['hswaps'];
    $lswaps = $singleStat['lswaps'];
    $today = $singleStat['today'];
    $tdpoints_temp = $singleStat['tdpoints_temp']-$playeridPoints;
    $tdpoints = $singleStat['tdpoints']-$playeridPoints;
    $htdpoints = $singleStat['htdpoints'];
    $ltdpoints = $singleStat['ltdpoints'];
} 

以外は問題ありません。「0」であるすべての変数 ($random、$hpoints、$lmoves、$lpasses、$lswaps、および $htdpoints) は、エコーすると「-」として出力されますか? 理由がわからないので、「0」を返してほしいです。

どんな助けでも大歓迎です、そして前もって感謝します:-)

//########### 編集 #############//

完全なコードは次のとおりです。

if($cacheAvailable == true){ // WE GOT A CACHE
    //$memcache->delete('stats_'.$opponent);
    $userStats = $memcache->get('stats_'.$opponent);

    echo '<pre>';
    print_r($userStats);
    echo '</pre>';

    foreach($userStats as $singleStat){
        $played = $singleStat['played'];
        $random = $singleStat['random'];
        $win = $singleStat['win'];
        $draws = $singleStat['draws'];
        $passes = $singleStat['passes'];
        $swaps = $singleStat['swaps'];
        $hpoints = $singleStat['hpoints'];
        $lpoints = $singleStat['lpoints'];
        $hmoves = $singleStat['hmoves'];
        $lmoves = $singleStat['lmoves'];
        $hpasses = $singleStat['hpasses'];
        $lpasses = $singleStat['lpasses'];
        $hswaps = $singleStat['hswaps'];
        $lswaps = (int)$singleStat['lswaps']; 
        $today = $singleStat['today'];
        $tdpoints_temp = $singleStat['tdpoints_temp']-$playeridPoints;
        $tdpoints = $singleStat['tdpoints']-$playeridPoints;
        $htdpoints = $singleStat['htdpoints'];
        $ltdpoints = $singleStat['ltdpoints'];
    }
    echo 'This swap: '.$lswaps.'<br><br>';
}
4

1 に答える 1