...

View Full Version : Resolved Is there a PHP command similar to mySQL LIKE 'search%'



fail
10-17-2011, 01:57 AM
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'

fail
10-17-2011, 02:46 AM
Doh!

...substr....



$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.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum