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 trialCoders Unlimited
10,112 Pointsstruck on ccodechallenge
I have this block of code that isn’t working correctly, but I can’t figure out the problem. It says that the name of my favorite flavor of ice cream ('Cookie Dough') does not contain the search term 'cookie', but it does. Can you take a look? Can you change it so that it checks that the value in $search_term is found within $flavor correctly?
5 Answers
Richard Duncan
5,568 Pointsstripos expects 2 parameters seperated by a comma , not a period .. So if you simply replace the period with a comma it will output:
Randy's favorite flavor of ice cream contains the search term 'vanilla'.
Coders Unlimited
10,112 Points<?php
$flavor = "Cookie Dough";
$search_term = "vanilla";
if (stripos($search_term.$flavor) !== true) {
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 . "'.";
}
?>
Coders Unlimited
10,112 PointsI am Struck on this task please help...TASK:2
Brian Enos
10,468 Points<?php
$flavor = "Cookie Dough";
$search_term = "vanilla";
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 . "'.";
}
?>
Coders Unlimited
10,112 Pointsthank you so much Richard Duncan I completed the task....
Richard Duncan
5,568 PointsNo worries. You could mark my answer if you wanted :D
Coders Unlimited
10,112 Pointsits k now i got the answer Richard
Richard Duncan
5,568 PointsI meant up vote or mark as best answer.
Coders Unlimited
10,112 Pointsya i did
Richard Duncan
5,568 PointsRichard Duncan
5,568 PointsPlease post the code.