Created
February 10, 2015 16:52
-
-
Save rodebert/aea57e1e94ebce5b49cc to your computer and use it in GitHub Desktop.
Statamic plugin to check if variable contains a 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 | |
class Plugin_contains extends Plugin { | |
public function index() { | |
$needle = $this->fetchParam('needle', '', null, false, false); | |
$haystack = $this->context[$this->fetch('haystack')]; | |
return strpos($haystack, $needle) ? $this->content : false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment