Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8960537
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:40:51+00:00 2026-06-15T15:40:51+00:00

I have this script… //initial value $fund = 10; $rebate = 0.01; // constant

  • 0

I have this script…

//initial value

$fund = 10;
$rebate = 0.01; // constant 1 percent
$maturity = 30; //days

echo '<ul>';
echo '<li>Day1 fund: $' . $fund . '</li>';

//day1 value
$fund = incfund($fund); //should return $10.10
echo '<li>Day2 fund: $' . $fund . '</li>';

//day2 value
$fund = incfund($fund); //should return $10.20
echo '<li>Day3 fund: $' . $fund . '</li>';

//day3 value
$fund = incfund($fund); //should return $10.30
echo '<li>Day4 fund: $' . $fund . '</li>';

echo '</ul>';
//continue increasing the fund value daily until day 30...


//function to increase $fund

function incfund($x){
for($i = 0; $i<=$maturity; $i++){
$newfund = $x + $rebate;
$fund = $newfund;
return $fund;
}
}

currently if I run the script, it will output:

Day1 fund: $10
Day2 fund: $10
Day3 fund: $10
Day4 fund: $10

when I really want to output is:

Day1 fund: $10.10
Day2 fund: $10.20
Day3 fund: $10.30
Day4 fund: $10.40
...
...
Day30 fund: $13.00

basically, what I want to do is compute the 1% rebate and compound it to the original fund and then continue compounding until the maturity date.

what could be the problem why I cannot do what I want?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T15:40:52+00:00Added an answer on June 15, 2026 at 3:40 pm

    Look at your code

    function incfund($x){
        for($i = 0; $i<=$maturity; $i++){
            $newfund = $x + $rebate;
            $fund = $newfund;
            return $fund;
        }
    }
    

    What it really do

    function incfund($x){
        return $x+$rebate;
    }
    

    What you should change

    function incfund($x){
        global $rebate;
        return $x+$rebate;
    }
    

    or

    function incfund($x, $rebate){
        return $x+$rebate;
    }
    

    And change view layer for

    for ($i = 1; $i <= $maturity; $i++, $fund = incfund($fund)) {
        echo '<li>Day'.$i.' fund: $' . $fund . '</li>';
    }
    

    But as you described your functionality all your code should look like

    //initial value
    
    $fund = 10;
    $rebate_weekdays = 0.01; // constant 1 percent
    $rebate_weekend = 0.02; // constant 1 percent
    $maturity = 30; //days
    
    echo '<ul>';
    
    // show fund and continue increasing the fund value daily until day 30...
    for ($i = 1; $i <= $maturity; $i++) {
        $rebate = (is_it_weekend($i)) ? $rebate_weekend: $rebate_weekdays;
        $curfund = incfund($fund, $i, $rebate);
        echo '<li>Day'.$i.' fund: $' . $curfund . '</li>';
    }
    
    echo '</ul>';
    
    //function to calculate current $fund    
    function incfund($fund, $x, $rebate){
        return $fund * (1 + $x * $rebate);
    }
    

    How to check that day you can find. It simply using http://php.net/mktime and http://php.net/date

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script #!/bin/sh if [ $# -ne 3 ] ; then echo
I have this script that is changing the value of an input field. The
I have this script called test.sh: #!/bin/bash STR = Hello World echo $STR when
I have this script that fetches some data from mysql and then uses echo
I have this script which calculates days until someone's next birthday (there's probably a
I have this script: function calculate(){ passworda = document.password1.user1.value.toLowerCase() passwordb = document.password1.pass1.value.toLowerCase() var user
I have this script #!/bin/sh for i in `ls -R` do echo Changing $i
I have this script that run to fix my menu bar to the browser
I have this script and need to be able to call the $play variable
I have this script set up that echoes all relevant users in a database

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.