Reputation: 875
How do I write this code correctly? The fourth line, I want to use the values of the two first keys all within the same array.
$pixel_percents = array(
"complete"=>.5 * 768,
"wip"=>round(.2 * 768, 0, PHP_ROUND_HALF_DOWN),
"remain"=>$pixel_percents["complete"] - $pixel_percents["wip"]
);
Upvotes: 1
Views: 68
Reputation: 49198
$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"];
Upvotes: 3
Reputation: 709
Just do it after
$pixel_percents = array(
"complete"=>.5 * 768,
"wip"=>round(.2 * 768, 0, PHP_ROUND_HALF_DOWN),
);
$pixel_percents['remain'] = $pixel_percents['complete'] - $pixel_percents['wip'];
Upvotes: 4