Simple Procedure: abcd accounts for 10%, 20%, 30%, 40%, and abcd10 respectively.

Source: Internet
Author: User

Simple Procedure: abcd accounts for 10%, 20%, 30%, 40%, and abcd10 respectively.

The income sequence of the four abcd projects accounts for 10%, 20%, 30%, and 40% respectively. If a project does not exist, the income of the project is the same as that of the previous project. Project a always exists, encapsulate a function to get the benefits of abcd;

This question is not difficult. The key point is to use arrays. If you think about it, you can do it.

Program code:

<? Php
/**
* Obtain 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' => 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 ));
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.