Last active
October 6, 2015 14:27
-
-
Save Loupax/a39e356f68da7b96f8ef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * SQL Like operator in PHP. | |
| * Returns TRUE if match else FALSE. | |
| * @param string $pattern | |
| * @param string $subject | |
| * @return bool | |
| */ | |
| function like_match($pattern, $subject) | |
| { | |
| $pattern = str_replace('%', '.*', preg_quote($pattern, '/')); | |
| return (bool) preg_match("/^{$pattern}$/i", $subject); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment