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 trial

PHP

Mimic Array Sum code challenge 2 of 3

what the heck am I missing?

<?php 

function mimic_array_sum($array) {
    $sum=0;
  foreach($array as $element) {
   $sum = $sum + $element;
  }
  return $sum;
};


$palindromic_primes = array(11, 757, 16361);
$sum =$mimic_array_sum($palindromic_primes);
echo $sum;
?>

5 Answers

also, why are my cheats not working?

Hello,

First off you need to use the three back-ticks with the word 'php' appended to the back-ticks for it to work. Now for your question, you don't need a semicolon after the closing bracket ( } ) of the function. Take the semicolon out and the code should work. In real-life,this code would throw up a parsing error.

Cheers!

still no worky

i'm about to throw a parsing error

Hello,

Found your error. You have a $ in front of the function when you call it. Remove the $ from the function call and you should be good.

Cheers!

oh yeah it's a function not a variable - cha-ching!