如何正确编写此代码?第四行,我想在同一个数组中使用两个第一个键的值。
$pixel_percents = array(
"complete"=>.5 * 768,
"wip"=>round(.2 * 768, 0, PHP_ROUND_HALF_DOWN),
"remain"=>$pixel_percents["complete"] - $pixel_percents["wip"]
);
答案 0 :(得分: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'];
答案 1 :(得分: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"];