The issue with your script is <?php>
However, you can make it shorter by, using range()
to create an array of all integers from 0 to 500, then array_sum()
to calculate the sum, then subtract 42.
echo array_sum( range(0,500) ) - 42;
0
solved need help for a function in php