Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robmorgan/279761 to your computer and use it in GitHub Desktop.
Save robmorgan/279761 to your computer and use it in GitHub Desktop.
<?php
// need a true/false return if a needle is found.
$haystack = "this is the haystack/string full of goodness needle 1 needle 2"; // haystack
$needles = array("needle 1", "needle 2", "needle 3"); // needles
foreach ($needles as $key => $val) {
if (strpos($haystack, $val)) {
// do something
echo 'found match';
} else {
// do something else
echo 'no match';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment