目前我的输出来了这样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