Can't figure out what's the problem


I can't figure this out. I know this is a simple function but I follow the instructions (well, maybe). Here is the instruction:
On line 6, use strpos() passing in your name as the haystack and a letter from your name as the needle.
On line 13, test if strpos() === false where the needle is not in the haystack. Print out an error message inside your if block.
The error is: Your first strpos() call should ouptut a number.

My code is:

    // Print out the position of a letter that is in
    // your own name
    strpos("marvin", "p");   
    strpos("marvin", "i"); 
    strpos("marvin", "ar"); 
    strpos("marvin", "zx");
    // Check for a false value of a letter that is not
    // in your own name and print out an error message
    if (strpos("marvin","zx") === false) {
    print "Sorry, no 'zx' in 'marvin'";

I'm new to PHP and want to learn about it. I'm a student and want to learn more. Please excuse my coding ability cause I'm no pro :frowning:


your code is True.

that say top sentence.

you get to position of that letter, but you must print that position. just insert print before strpos(...) in first part.


Thank you! :slight_smile: I worked and now I can advance to the next lesson :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.