ABCD four project revenue sequence accounted for 10%,20%,30%,40%, when there is a project does not exist when the project proceeds to a project, project A always exists, encapsulating a function to obtain the benefits of ABCD;
This problem is not difficult, the key point is to think of using arrays, this thought, that certainly can be done.
Program code:
<?php
/**
* Get Project Benefits
* @param null $b
* @param null $c
* @param null $d
* @return Array
*/
function getincome ($b = null, $c = NULL, $d = NULL)
{
$income = [' a ' = = 0.1, ' b ' = = 0.2, ' c ' = 0.3, ' d ' and ' 0.4];
if (! $d) {
$income [' c '] + = $income [' d '];
$income [' d '] = 0;
}
if (! $c) {
$income [' b '] + = $income [' C '];
$income [' c '] = 0;
}
if (! $b) {
$income [' a '] + = $income [' B '];
$income [' b '] = 0;
}
return $income;
}
Echo ' <pre> ';
Var_dump (getincome (1, 0, 0));
?>
Simple program title: ABCD Four project revenue sequence accounted for 10%,20%,30%,40%