PHP - Equation Breakdown
Hi
I have built a series of forms with PHP and have been using SESSIONS to carry values from one to another. In one, the value of a variable is determined by adding the values of several other variables together: Code: [Select] $totalFixed = $fixedCost1 + $fixedCost2 + $fixedCost3 + $fixedCost4 + $fixedCost5;This equation is working fine on that page. I then place the value of $totalFixed in a SESSION variable: Code: [Select] $_SESSION['totalFix']=$totalFixed;I then assign this SESSION variable's value to a new variable on another page in the series: Code: [Select] $dataValue[4] = $_SESSION['totalFix'];The number displays fine on this page as well. However, when the value is above 1,000 and I try to subtract another number from it, it ignores everything to the right of the comma. For example, if $dataValue[4] is 10,132 and $dataValue[5] is 25 and I subtract $dataValue[4] from $dataValue[5], the result is -15. Does anyone know the reason for this? Many thanks, Andy Similar TutorialsIm new to PHP and have had success with much help from the community and am greatly thankful for all input. I have a pretty good understanding of what needs to be done, but actually implementing and accomplishing is difficult for me. Im trying to break down hierarchy from an existing HTML list. First Id like to point out that I am working with an HTML file that I must use, and cannot change, as the source. I am rewriting onto another file, removing HTML, and so forth. I have already accomplished this. But what I would really like to keep the hierarchy structure by breaking it down first, so I can also use that later. Example HTML list Code: [Select] <ul><li>modem, UP</li> <ul><li>wifiRouter, UP</li> <ul><li>PC1, DOWN</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> <ul><li>wiredRouter, UP</li> <ul><li>server, UP</li> <ul><li>dnsServer, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> <ul><li>webServer, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> <ul><li>PC2, UP</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> <!-- Up one level --> </ul> <!-- Up one level --> <ul><li>modemBackup, DOWN</li> <ul></ul> <!-- Open-close of UL identifies end --> </ul> Desired Output: Code: [Select] 1, 0, 0, 0, modem, UP 1, 1, 0, 0, wifiRouter, UP 1, 1, 1, 0, PC1, DOWN 1, 2, 0, 0, wiredModem, UP 1, 2, 1, 0, server, UP 1, 2, 1, 1, dnsServer, UP 1, 2, 1, 2, webServer, UP 1, 2, 2, 0, PC2, UP 2, 0, 0, 0, modemBackup, DOWN If im logically looking at this right (1) Count <ul> entry and continue counting for each group (2) Stop group count at end argument <ul></ul> (3) The immediate next end argument </ul>, following (2), says to continue counting the previous group +1 (4) Repeat steps 1-3 until end Any advise? Getting the difference in seconds between two timestamps is easy. Taking the seconds and doing a breakdown of time frames is also easy. Code: [Select] <?php echo '<p>There are a total of ' . round($seconds) . ' seconds between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round($seconds / 60) . ' minutes between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round(($seconds / 60) / 1440) . ' days between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round((($seconds / 60) / 1440) / 7) . ' weeks between Timestamp 1 and Timestamp 2.</p>'; echo '<p>There are a total of ' . round((((($seconds / 60) / 1440) / 7) / 30)) . ' months between Timestamp 1 and Timestamp 2.</p>'; echo '<p>The total breakdown of time from Timestamp 1 to Timestamp 2 is .</p>'; ?> What I am trying to figure out, is get a collective amount as well.... X years X months X weeks X days X minutes and X seconds. Does anyone have any good algorithm for handling that, or have any feedback on where to start to handle this type of math. Code: [Select] if ($user['amount'] >= 15.00){ $user['max_stars'] = 3; } Ok and Code: [Select] if ($user['amount'] >= 20.00){ $user['max_stars'] = 4; }How can I write a function that will loop through the 15,20,25,30,35, all the way up to 600$ or if the max_Stars get's up to 80? I really don't want to have 80 if functions in my code :\ |