From the course: Learning PHP

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Solution: Implementing a complicated calculation

Solution: Implementing a complicated calculation - PHP Tutorial

From the course: Learning PHP

Start my 1-month free trial

Solution: Implementing a complicated calculation

(bright music) - [Instructor] All right, let's walk through the solution for this challenge. First, we'll set up our results array, like so, then we'll evaluate the first statement. So I'll write results, square brackets and then we'll write the arithmetic operation. So first off, there are parentheses around most of it. So we'll do parens 14 plus 82 minus and then we have 32 divided by two. We want to make sure that this is evaluated first because of proper PEMDAS rules. So we'll wrap that part in parentheses and then make sure we have our parentheses properly spaced. After that, we are dividing, then we need to square the entire statement and we'll do that by adding our double asterisks and two. So there's our first results. We can do the same thing for the rest of the results as far as assignments go. That's the beauty of using an array and so, now we have 18 times three divided by six minus nine, in…

Contents