2011-09-24 103 views
1

如何正確寫入此代碼?第四行,我想在同一個數組中使用兩個第一個鍵的值。在同一個數組中使用相同的密鑰值

$pixel_percents = array(
    "complete"=>.5 * 768, 
    "wip"=>round(.2 * 768, 0, PHP_ROUND_HALF_DOWN), 
    "remain"=>$pixel_percents["complete"] - $pixel_percents["wip"] 
); 

回答

4

只要做到這一點後

$pixel_percents = array(
    "complete"=>.5 * 768, 
    "wip"=>round(.2 * 768, 0, PHP_ROUND_HALF_DOWN), 
); 
$pixel_percents['remain'] = $pixel_percents['complete'] - $pixel_percents['wip']; 
3
$pixel_percents = array(); 
$pixel_percents["complete"] = .5 * 768; 
$pixel_percents["wip"] = round(.2 * 768, 0, PHP_ROUND_HALF_DOWN); 
$pixel_percents["remain"] = $pixel_percents["complete"] - $pixel_percents["wip"]; 
相關問題