This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

252 points
Eb985ff7239e095a94a044521b0f96ab?s=140&d=retro
Submitted by
amal.1996
almost 2 years ago

3/8 Oops, try again. Your first strpos() call should output a number.

Help

<?php
// Print out the position of a letter that is in
// your own name
strpos("Amal","A"); //0
strpos("Amal","m"); //1
strpos("Amal","a"); //2
strpos("Amal","l"); //3
strpos("Amal","n"); //false
?>
</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("Amal","n") === false) { print "Sorry, no 'n' in 'Amal'";}
?>

6 votes

permalink

strpos("Amal","A"); //0
strpos("Amal","m"); //1
strpos("Amal","a"); //2
strpos("Amal","l"); //3
strpos("Amal","n"); //false

You need to add ECHO before strpos
so it would look like :
echo strpos("Amal","A"); //0
echo strpos("Amal","m"); //1
echo strpos("Amal","a"); //2
echo strpos("Amal","l"); //3
echo strpos("Amal","n"); //false
This'll output a number!

558 points
54845ec2dd5d79a84919d6d928727baa?s=140&d=retro
Submitted by
LexyHudson
almost 2 years ago

3 Comments

Eb985ff7239e095a94a044521b0f96ab?s=140&d=retro amal.1996 almost 2 years ago

thx

2b98bd099ad9626a738bc80deaee8213?s=140&d=retro mwlvis01 almost 2 years ago

thx

Ba2be097b0818ab40d5e43f55e9ac214?s=140&d=retro kim_limaa almost 2 years ago

Thanks man, helped a lot!