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 2 of 2

Thread: strchr()

  1. #1
    Senior Coder
    Join Date
    Jul 2005
    Location
    UK
    Posts
    1,051
    Thanks
    6
    Thanked 13 Times in 13 Posts

    strchr()

    Note: Realised my error and fixed, please ignore this post. I had misread strchr, it should be strrchr in the code below .

    From php.net:

    string strrchr ( string $haystack, string $needle )

    This function returns the portion of haystack which starts at the last occurrence of needle and goes until the end of haystack.
    Given the above, shouldn't the following code echo "/foo.htm"?

    PHP Code:
    $url "http://www.domain.com/foo.htm";
    $exc strchr($url"/");
    echo 
    $exc
    For me it's returning "//www.domain.com/foo.htm" which seems to be a portion that starts at the first occurence of needle and goes until the end of haystack (ie, the written purpose of strstr())
    .
    Last edited by Pennimus; 03-07-2007 at 04:24 PM.

  • #2
    New Coder
    Join Date
    Sep 2006
    Location
    Lithuania
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    emm you quoted function strrchr form php.net, but you using strchr witch is alias of strstr function


  •  

    Posting Permissions

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