Skip to content

Instantly share code, notes, and snippets.

@juniorb2ss
Last active April 12, 2016 17:03
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 juniorb2ss/c77fa8b24d704294431f8626ca2d626c to your computer and use it in GitHub Desktop.
Save juniorb2ss/c77fa8b24d704294431f8626ca2d626c to your computer and use it in GitHub Desktop.
<?php
$string = 'http://meusite.com.br/wp-admin.php';
$BlackListURL = ["wp-admin.php", "admin", "administrator", "wp-login.php"];
/** Procure por uma parte da string no texto **/
function hasString($search, $text, &$found) {
if (!is_array($search)) {
$search = [
$search,
];
}
foreach ($search as $keys => $value) {
$position = strpos($text, $value);
if ($position !== false) {
$found = $value;
return true;
}
}
return false;
}
#
$hasString = hasString($BlackListURL, $string, $found);
var_dump($hasString); // true
var_dump($found); // wp-admin.php
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment