## Functions, Part I Forum View Course » View Exercise

``````<?php
``````

// Print out the position of a letter that is in
\$pos = strpos("Larry", "y");
print \$pos;

?>

<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos("Larry", "j") === false) {
print "Sorry, no 'j' in 'Larry'";
}
?>

``````<html>
<p>
<?php
// Print out the position of a letter that is in
\$pos = strpos("david", "v");
print \$pos // prints 2
?>
</p>
<p>
<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos("david", "h") === false) {
print "Sorry, no 'h' in 'david'";
}
?>
</p>
``````

Natalie Rodriguez over 4 years ago

this works

anonymous over 4 years ago

thx lots

Hunter Steele over 3 years ago

totally wrx thnx

Unfortunately, there are a lot of issues in that PHP course...

try using variables for the input of strpos()

``````\$name = "Brian";
\$letter = "b"
\$pos = strpos(\$name,\$letter);
print \$pos;
``````

and for the second task change the letter variable and print it:

``````\$letter = "s";
if(\$pos == false){
print "Sorry, no '{\$letter}' in '{\$name}'";
};
``````

Hope that helps! - Niksda

this code just work for me

``````<html>
<p>
<?php
// Print out the position of a letter that is in
// Print out the position of a letter that is in
``````

\$pos = strpos("Larry", "y");
print \$pos;
?>

<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos("Larry", "j") === false) {
print "Sorry, no 'j' in 'Larry'";
}
?>

``````</p>
``````

This code worked for me.......

<?php
// Print out the position of a letter that is in
\$pos = strpos ("Brian","i");
echo \$pos
?>

<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
if (strpos ("Brian", "x")==false){
echo "Sorry, no x in Brian";
}
?>

A lot of issues again and again...

Is there a way to just skip this section because my code works but codecademy doesnt think it does.

##### 1 Comment

daireof over 4 years ago

put it between p tags " <?php code ?>"
if that doesn't work i'll send you solution

in your if statement, it should be '==' not '==='

##### 1 Comment

Menixator over 4 years ago

both of them should work.

I had problem passing this part even though my code was correct. What fixed it was removing the < p > around the message.

I've had no problems with this exercise. The code below works fine using variables...

``````<?php
// Print out the position of a letter that is in
\$haystack = "Mark Phoenix";
\$needle = "k";
echo strpos(\$haystack, \$needle);
?>
</p>
<p>
<?php
// Check for a false value of a letter that is not
// in your own name and print out an error message
\$needle = "y";
if (!strpos(\$haystack, \$needle)){
echo "Sorry, no '\$needle' in '\$haystack'";
}
?>
``````