目前我的輸出來了這樣PNL測試1,10,PNL測試2.55,我想操縱它,它在兩個不同的變量存儲爲喜歡的字符串:
$車隊 =「PNL測試1,PNL測試2」;
$ amount =「10,55」;
請讓我知道我應該如何拆分上述格式。
代碼
while ($row1 = mysql_fetch_assoc($result)){
$profit = 0;
$total = 0;
$loss = 0;
$final_array = '';
$final_array .= $teams = $row1['t_name'].",";
$teams = explode(",", $teams);
$transact_money = $row1['pnl_amount'];
$pnl_results = $row1['pnl'];
$transact_money = explode("|", $transact_money);
$pnl_results = explode("|", $pnl_results);
for($i=0; $i<count($transact_money); $i++){
if($pnl_results[$i]=='Profit'){
$profit = $profit + $transact_money[$i];
}else{
$loss = $loss + $transact_money[$i];
}//end if
}//end for..
$team_profits = $profit - $loss.",";
$final_array .= $team_profits;
echo $final_array;
}
爲什麼不拆出while循環的結果? – 2013-04-25 16:10:47