Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.
Rob Salaman1,915 Points
I can't preview because the preview button doesn't work
I'm not sure how to use the array_sum function and I was going to test through the preview button; however it's not working.
array_sum() function takes any number values it finds in an array and sums them together. It has only one argument which is the array to get the sum of. So, with that in mind, you only need the
$sum variable in order to store the sum from the
array_sum() function and then echo that result out to the page:
<?php $numbers = array(1,5,8); //store the sum of the array in this variable $sum = array_sum($numbers); //then output to page echo $sum; ?>
Here is the reference for the
array_sum() function: http://php.net/manual/en/function.array-sum.php