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 trialRobert Olivam
28,843 PointsIssue with PHP Code Challenge: "Using Strpos: Searching for Cookie"
The code challenge starts out written correctly, and it actually forces you to make the code incorrect in order to move on to step two. Once in step two, it no longer accepts the incorrect code, and forces you to change it back to what it was in order to complete the challenge.
On a side note, the challenge name refers to the function “Strpos” when we’re actually using “Stripos”, which is relevant to the challenge, as “cookie” is not capitalized but “Cookie Dough” is. The other challenges in the same section correctly name it as “Stripos”.
2 Answers
elad sivan
10,702 PointsIt happened to me, took me a while to figure out what the trick, try this: Apparently your code looks like this:
if (stripos($var1,$initial) == 0 && stripos($var2,$initial) == 1)
But it should be like this:
if (stripos($var1,$initial) == 0 && stripos($var2,$initial) == 0)
change the 1 at the end to 0, and its gonna work.
Miguel Angel Rodriguez
11,280 Pointsif (stripos($flavor, $search_term) !== false) {
Ken Stone
6,648 PointsKen Stone
6,648 PointsI'm just a few sections away from this one. I'm up to: http://teamtreehouse.com/library/enhancing-a-simple-php-application/adding-search-model/introducing-identity-comparison