Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMUZ140264 Tsitsi Mupamombe
4,195 Pointschallenge. 3. of. 3.. how. do. i. answer. this. question
how. do. i. answer. this. question
<?php
function mimic_array_sum($array){
$sum=0;
foreach($array as $element){
$sum = $sum + $element;
}
return $sum;
}
$sum = mimic_array_sum($palindromic_primes);
echo $sum;
$palindromic_primes = array(11, 757, 16361);
?>
1 Answer
Jeff Lemay
14,268 PointsIt looks like you just need to move your $palindromic_primes array above the lines where you call the function and echo the result.
With how your code is now, you are running the function and trying to echo the sum before your array has been set, so your palindromic_primes aren't being passed into the function.
Jeff Lemay
14,268 PointsJeff Lemay
14,268 Points