This code should help you:
<?php
i = 1;
i++) {
sum + $i;
}
echo $sum;
?>
You are incorrect using loop.
Explanation
I think it will be easier to understand with following table:
_____________________
|JUMP |
sum |
|1 | 1 | 1 |
|2 | 2 | 3 |
|3 | 3 | 6 |
|4 | 4 | 10 |
|5 | 5 | 15 |
|6 | 6 | 21 |
|7 | 7 | 28 |
|8 | 8 | 36 |
|9 | 9 | 45 |
|10 | 10 | 55 |
More about for you can read in PHP: for
Update
If you want your structure it can be as follows:
<?php
str = '';
for(
i<=10; $i++) {
$sum =
i;
i == 10 ?
i." + ";
}
echo
sum;
?>
And it will output 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
Top answer 1 of 7
18
This code should help you:
<?php
i = 1;
i++) {
sum + $i;
}
echo $sum;
?>
You are incorrect using loop.
Explanation
I think it will be easier to understand with following table:
_____________________
|JUMP |
sum |
|1 | 1 | 1 |
|2 | 2 | 3 |
|3 | 3 | 6 |
|4 | 4 | 10 |
|5 | 5 | 15 |
|6 | 6 | 21 |
|7 | 7 | 28 |
|8 | 8 | 36 |
|9 | 9 | 45 |
|10 | 10 | 55 |
More about for you can read in PHP: for
Update
If you want your structure it can be as follows:
<?php
str = '';
for(
i<=10; $i++) {
$sum =
i;
i == 10 ?
i." + ";
}
echo
sum;
?>
And it will output 1 + 2 + 3 + 4 + 5 + 6 + 7 + 8 + 9 + 10 = 55
2 of 7
7
Something like this perhaps?
$range = range(1, 10);
$sum = array_sum($range);
echo implode(' + ', $range) . ' = ' . $sum;
range() - http://php.net/range
array_sum() - http://php.net/array_sum
implode() - http://php.net/implode
W3Schools
w3schools.com › php › php_looping_for.asp
PHP for loop
The for loop is used when you know how many times the script should run. for (initialization; condition; increment) { // code to be executed } ... increment - is evaluated after each iteration (typically used to increase/decrease the counter ...
Filo
askfilo.com › cbse › smart solutions › display the numbers from 1 to 10 using php.
Display the numbers from 1 to 10 using PHP.... | Filo
December 25, 2025 - <?php for (<span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.65952em;vertical-align:0em;"></span><span class="mord mathnormal">i</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right:0.2777777777777778em;"></span></span><span class="base"><span class="strut" style="height:0.8388800000000001em;vertical-align:-0.19444em;"></span><span class="mord">1</span><span class="mpunct">;</span></span></span></span>i <= 10; i . "<br>"; } ?> ... <?ph
W3Resource
w3resource.com › php-exercises › php-for-loop-exercises.php
PHP for loop - Exercises, Practice, Solution - w3resource
March 31, 2026 - This resource offers a total of 190 PHP for loop problems for practice. It includes 38 main exercises, each accompanied by solutions, detailed explanations, and four related problems. [An Editor is available at the bottom of the page to write and execute the scripts.] ... Create a script that displays 1-2-3-4-5-6-7-8-9-10 ...
Steemit
steemit.com › world-of-xpilar › @rme › coding-practice-write-a-program-in-php-to-print-1-10-numbers-in-ascending-order-and-descending-order-by-running-for-loop
Coding Practice: Write a program in PHP to print 1-10 numbers in ascending order & descending order by running for loop — Steemit
March 8, 2026 - " "; } print "<br>"; //run a for loop to print 1-10 numbers in descending order for($i=$numbers; $i>=1; $i--) { //output numbers in descending order print $i . " "; } //end of php code ?> </body> </html> Output · 1 2 3 4 5 6 7 8 9 10 10 9 8 7 6 5 4 3 2 1 · Do it yourself on online PHP compiler: ...
Chegg
chegg.com › engineering › computer science › computer science questions and answers › 1. write a php code to display count, from 1 to 10 using php loop as given below. rules 8 hint - you can use "for" or "while" loop - you can use variable to initialize count - you can use html tag for line break 2. write a php program to find the length of the string: "php program" - you have to use one variable. - you must use a built-in php string
PHP code to display count , from 1 to 10 using PHP loop
May 4, 2023 - <h1>Counting from 1 to 10 using PHP</h1> <h2>Using a for loop</h2> <p> <?php for ($count = 1; $count <= 10; $count++) { echo $count .
Codecademy
codecademy.com › docs › php › loops
PHP | Loops | Codecademy
September 9, 2021 - Copy to clipboard · Output: the ... and immediately starts the next iteration. <?php · for ($i = 1;$i <= 10; $i++) { if ($i % 2 == 1) {continue; } echo 'iteration #' ....
Laracasts
laracasts.com › discuss › channels › laravel › how-to-do-a-foreach-loop-for-1-10
How to do a foreach loop for 1-10
<select name="immersiveScore" id="immersiveScore" class="form-control" required> <option value="" hidden>Choose Immersive Score</option> <option value="1">1</option> <option value="2">2</option> <option value="3">3</option> <option value="4">4</option> <option value="5">5</option> <option value="6">6</option> <option value="7">7</option> <option value="8">8</option> <option value="9">9</option> <option value="10">10</option> </select> but this seems like the wrong way to do it if I have access to PHP.
Scaler
scaler.com › home › topics › php-tutorial › php for loop
PHP For Loop - Scaler Topics
April 13, 2024 - Now let us see a few examples of for loops in PHP: ... In this example, we are using the range() function to create an array of numbers from 1 to 9, and then using a for each loop to iterate over the array and print each number.
Chegg
chegg.com › homework-help › questions-and-answers › write-following-php-code-1-use-loop-print-numbers-1-10-screen-2-use-loop-print-numbers-1-2-q93129337
Solved Write the following PHP code 1) Use a for loop to
February 25, 2022 - Ask any question and get an answer from our subject experts in as little as 2 hours.
Codecademy
codecademy.com › learn › learn-php › modules › php-loops › cheatsheet
Learn PHP: Loops in PHP Cheatsheet | Codecademy
In PHP, the foreach loop is used for iterating over an array. The code block is executed for every element in the array and the value of that element is available for use in the code block.
GeeksforGeeks
geeksforgeeks.org › php › php-loops
PHP Loops - GeeksforGeeks
April 10, 2025 - PHP for loop is used when you know exactly how many times you want to iterate through a block of code. It consists of three expressions: Initialization: Sets the initial value of the loop variable. Condition: Checks if the loop should continue. Increment/Decrement: Changes the loop variable after each iteration. ... Example: Printing numbers from 1 to 5 using a for loop.