Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Strpos trouble

  1. #1
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post

    Strpos trouble

    I have been reading the documentation at PHP.net but I must be missing something. The following code is failing to find the $needle in the $hay.

    PHP Code:
    $needle ='CNC';
    $hay 'CNC, Inspection';
    echo 
    $needle ":".$hay.'<br />';
    $pos strpos($hayneedle);
    if (
    $pos === false$pos='not found';
    echo 
    'result:'.$pos.'<br>'
    No matter how I play with this it never find the string. What am I doing wrong here?

    Thanks
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #2
    New Coder
    Join Date
    Jun 2007
    Location
    Canada
    Posts
    49
    Thanks
    1
    Thanked 1 Time in 1 Post
    Doh! I see it now. Might help to have the $ infront the needle. Sorry to bother you people.
    Of all the things I've lost in my life time, my mind is the one I miss the most!

  • #3
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,174
    Thanks
    19
    Thanked 66 Times in 65 Posts
    If you've copied and pasted this directly from your code then I think your problem is quite simple... its on this line

    PHP Code:
    $pos strpos($hayneedle); 
    You'll kick yourself when you spot it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •