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 trial

PHP Enhancing a Simple PHP Application Adding Search: Model Using stripos: Starts with C

Tolga CANATAN
Tolga CANATAN
8,995 Points

Adding Search: Model

Hi Everyone,

I have a one problem with Adding Search: Model Challenge.

Challenge Task 2 of 2:

I'm editied

$var2 = "Chocolate"; . But doesn't work. I know, I'ts very easy challenge but I was not pass :)

What can I do ?

Thanks.

2 Answers

Logan R
Logan R
22,989 Points

I just gave it a go, and it worked fine for me. Did you try and make sure that both had === not just one?

I would maybe just refresh and try it again. You are straight substituting into the $var2 = "Cholocolate".

<?php

    $var1 = "Cookie Dough";
    $var2 = "Chocolate";
    $initial = "C";

    if (stripos($var1,$initial) === 0 && stripos($var2,$initial) === 0) {

        echo $var1 . " and " . $var2 . " both start with " . $initial . ".";

    } else {

        echo "Either " . $var1 . " or " . $var2 . " doesn't start with " . $initial . "; maybe neither of them do.";

    }

?>

Hope this helped :)

Tolga CANATAN
Tolga CANATAN
8,995 Points

Thank you very much L R :)