• 07-02-2023, 21:08:15
    #1
    Merhaba
    Aşağıdaki json dosyasında pnl sayısının toplamını nasıl yazdırabilirim
    {"code":"000000","message":null,"messageDetail":null,"data":{"otherPositionRetList":[{"symbol":"DOGEUSDT","entryPrice":0.0894190965988,"markPrice":0.09230140,"pnl":322.36907964,"roe":0.62454307,"updateTime":[2023,2,6,23,42,56,941000000],"amount":111844,"updateTimeStamp":1675726976941,"yellow":false,"tradeBefore":false,"leverage":20},{"symbol":"FXSUSDT","entryPrice":10.76942489636,"markPrice":12.89000000,"pnl":2132.02621559,"roe":1.15159232,"updateTime":[2023,2,6,18,35,42,116000000],"amount":1005.4,"updateTimeStamp":1675708542116,"yellow":false,"tradeBefore":false,"leverage":7}],"updateTime":[2023,2,6,18,35,42,116000000],"updateTimeStamp":1675708542116},"success":true}
  • 07-02-2023, 21:21:54
    #2
    <?php
    $json = $gelenveri;
    
    $data = json_decode($json, true);
    
    $total_pnl = 0;
    foreach ($data['data']['otherPositionRetList'] as $position) {
        $total_pnl += $position['pnl'];
    }
    
    echo "Toplam PNL: " . $total_pnl;
    ?>
  • 07-02-2023, 21:25:02
    #3
    murqlegend adlı üyeden alıntı: mesajı görüntüle
    <?php
    $json = $gelenveri;
    
    $data = json_decode($json, true);
    
    $total_pnl = 0;
    foreach ($data['data']['otherPositionRetList'] as $position) {
        $total_pnl += $position['pnl'];
    }
    
    echo "Toplam PNL: " . $total_pnl;
    ?>
    Çok teşekkürler hocam.+R10