Skip to content

Instantly share code, notes, and snippets.

@saltun
Created May 16, 2015 18:30
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 saltun/6b2f1e8a9971dbcb592c to your computer and use it in GitHub Desktop.
Save saltun/6b2f1e8a9971dbcb592c to your computer and use it in GitHub Desktop.
PHP strpos in array function
<?php
/**
* @author Savaş Can ALTUN <savascanaltun@gmail.com>
* @link http://savascanaltun.com.tr
* PHP strpos function in array
*/
function strposa($text, $finds, $offset=0) {
if(!is_array($finds)) $finds = array($finds);
foreach($finds as $query) {
if(strpos($text, $query, $offset) !== false) return true;
}
return false;
}
$text="My favorite language PHP";
$finds=array("asp","php","python");
/**
* Text search keywords
* @return true|false
*/
var_dump(strposa($text, $finds)); // false
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment