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

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'

10-17-2011, 02:46 AM


$str = 'sdfhjsdhfjkh.com';
$last = substr($str, -4);

echo $last;

// returns '.com'

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