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 trialscavence
11,300 PointsPHP Development Code Challenge
Must be overlooking something but can't figure it out.
$flavor = "Vanilla";
$search_term = "cookie";
if (stripos($flavor,$search_term) !== false) {
echo "Randy's favorite flavor of ice cream contains the search term '" . $search_term . "'.";
} else {
echo "Randy's favorite flavor of ice cream does NOT contain the search term '" . $search_term . "'.";
}
In the first case the stripos($flavor,$search_term) were switched.
If(stripos(the case insensitive string position) is not a false match to the object -> !== it should echo out the correct sentence, in this case the second statement.
What am I missing?
2 Answers
Logan R
22,989 PointsYou changed the wrong value, it wants you to change the search value, not the flavor.
$flavor = "Cookie Dough";
$search_term = "vanilla";
Good luck!
scavence
11,300 PointsI was too focused on the logic that I forgot to read carefully it seems. Thanks!
Logan R
22,989 PointsIt's all good :) I've done it before too.
James Andrews
7,245 PointsJames Andrews
7,245 PointsWhen I tried the above code it gave me the 2nd sentence as the answer so it seems to be working the way you describe