## 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!

### 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###### Fernando Gomez

18,527 Points# what's wrong with my code?

```
function mimic_array_sum($array) {
$sum = 0;
foreach($array as $element) {
$sum = $sum + 1;
}
return $sum;
}
$palindromic_primes = array(11, 757, 16361);
$sum = mimic_array_sum($palindromic_primes);
echo $sum;
?>
```

## 4 Answers

###### Adam Sackfield

Courses Plus Student 19,663 PointsThis is everything in the code editor when I just passed it again.

Question 2

```
<?php
function mimic_array_sum($array) {
$sum = 0;
foreach($array as $element) {
$sum = $sum + $element; // Not 1
}
return $sum;
}
$palindromic_primes = array(11, 757, 16361);
?>
```

Question 3

```
<?php
function mimic_array_sum($array) {
$sum = 0;
foreach($array as $element) {
$sum = $sum + $element; // Not 1
}
return $sum;
}
$palindromic_primes = array(11, 757, 16361);
$sum = mimic_array_sum($palindromic_primes);
echo $sum;
?>
```

###### Adam Sackfield

Pro Student 19,663 PointsTook me a while but it should be this think you must have had a momentary lapse in concentration

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

###### Fernando Gomez

18,527 Pointsstill not working.....I changed it to $sum = $sum + $element

###### Fernando Gomez

18,527 PointsThank you Adam! Now it worked. I think I was getting ahead of myself, and I was doing question 3 in question 2, and I think that's the reason it wasn't going through.

###### Adam Sackfield

Pro Student 19,663 PointsI concur :)

Now its solved click best answer and others can see then.

Good Luck!