How do I make my first strpos() call output a number?


Functions, Part 1 - String Functions II

How do I print out the position of a letter in my name?

    // Print out the position of a letter that is in
    // your own name
    strpos("jamie", "j"); // 0
    strpos("jamie", "a");  // 1
    strpos("jamie", "mie"); // 
    strpos("jamie", "z");
    // Check for a false value of a letter that is not
    // in your own name and print out an error message
    if (strpos("jamie", "z") === false) {
        print "Sorry, no 'z' in 'jamie";


Hi try that

echo strpos("jamie", "j"); // 0


That works! Thanks!

Maybe I overlooked this before but when do you use 'print' vs 'echo' to output data?


YOu can find it here


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