Jump to content

STRPOS not working per W3S documentation


mickeymouse

Recommended Posts

Posted (edited)

Can someone tell me what I'm doing wrong?
    I believe it's correct code but it doesn't work.

   I get FOUND no matter what I have in $newnum.

    
    $mynums="01-05-15-32-64-81-99";
    $newnum="64";
    $numpos=strpos($mynums,$newnum);
    if($numpos<>FALSE)
        {print("FOUND");}
    else{print("NOT FOUND");}

Thank you

Edited by mickeymouse
Link to comment
Share on other sites

I just tested your code and it seemed to be working properly. With $newnum="20" it prints "NOT FOUND".

Which values of $newnum did you test with?

I would check the value of $numpos with the var_dump() function to see what its value is. That will tell you where in the string it found the number.

var_dump($numpos);

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...