Created
May 3, 2014 01:12
-
-
Save madeinnordeste/2a96fc07059466e62075 to your computer and use it in GitHub Desktop.
PHP - Check if a string contains another string
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 | |
function contains($str, $content, $ignorecase=true){ | |
if ($ignorecase){ | |
$str = strtolower($str); | |
$content = strtolower($content); | |
} | |
return strpos($content,$str) ? true : false; | |
} | |
var_dump(contains('hello world', 'world')); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment