Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save madeinnordeste/2a96fc07059466e62075 to your computer and use it in GitHub Desktop.
Save madeinnordeste/2a96fc07059466e62075 to your computer and use it in GitHub Desktop.
PHP - Check if a string contains another string
<?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