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
  1. #1
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts

    Is there a PHP command similar to mySQL LIKE 'search%'

    Sorry, I get confused with all those php string commands...

    What is the PHP command most similar to mySQL LIKE '%search' ?

    Example: I want to match '*.com' but not '*.com.uk'
    Last edited by fail; 10-17-2011 at 03:48 AM.

  • #2
    Regular Coder
    Join Date
    Dec 2009
    Location
    Hong Kong
    Posts
    119
    Thanks
    8
    Thanked 0 Times in 0 Posts
    Doh!

    ...substr....

    PHP Code:
    $str 'sdfhjsdhfjkh.com';
    $last substr($str, -4); 

    echo 
    $last;

    // returns '.com' 

    @kbluhm
    I know preg_match, but I find that intimidating and use it only when really nothing else can do.
    Last edited by fail; 10-17-2011 at 03:48 AM.


  •  

    Posting Permissions

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