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 trialNthulane Makgato
Courses Plus Student 19,602 PointsIntroducing strpos
I've been struggling with this simple quiz. I would have thought that the answer was 6 if you consider "Chocolate", "C" being 0 and counting from there.
<?php
$flavors = array("Chocolate","Vanilla","Strawberry","Cookie Dough");
echo strpos($flavors[1],"a");
?>
Thank you in advance.
2 Answers
George Cristian Manea
30,787 PointsThe answer is 1 because $flavors[1] = "vanilla", chocolate is $flavors[0]
Nthulane Makgato
Courses Plus Student 19,602 PointsAh... thank you very much George, I thought it was something that simple.
George Cristian Manea
30,787 Pointsyou're welcome, can you set the answer as "best answer" please :)