I cannot figure out how to fix my code someone please please help me


#1



<?php
// Print out the position of a letter that is in
// your own name
strpos( "Gabe", "0");
?>



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



#2

<?php
// Print out the position of a letter that is in
// your own name
strpos( "Gabe", "0");
?>

Here you need to output a number. So, let's say you want to find the position of b within Gabe, you need to output the position of b.


#3

how would i do that? I tried figuring it out for a couple of hours and havent figured it out


#4

What you could do is create a variable, and assign what you currently have to this variable.

You would then simply print the variable. I think that is simple enough.

But you'll also have to modify your current code a bit, like this

strpos("Gabe", "b");

(that is, if you want to know the position of b. Could be any other letter!) :wink:


#5

that took me beyond too long thank you!


#6

The strpos () method returns the position of a substring within the input-string. If the substring is not found, then the result is false.
you could do it like this:
$name = "Denny"; //assign the input-string to a variable
strpos($name, "e"); // return's true
strpos($name, "r"); return's false


#7

thank you! i for some reason could just not figure this out and its ridiculous but thank you so much


#8

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