note 105984 modified in function.strpos by levim
| From: | levim@php.net | Date: | Tue, 22 Jul 2014 03:19:05 +0000 |
| Subject: | note 105984 modified in function.strpos by levim | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-200006@lists.php.net to get a copy of this message | ||
strpos that accepts an array for $needle
<?php
// strpos that takes an array of values to match against a string
// note the stupid argument order (to match strpos)
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
?>
--was--
strpos that accepts an array for $needle
<?php
// strpos that takes an array of values to match against a string
// note the stupid argument order (to match strpos)
function strpos_arr($haystack, $needle) {
if(!is_array($needle)) $needle = array($needle);
foreach($needle as $what) {
if(($pos = strpos($haystack, $what))!==false) return $pos;
}
return false;
}
?>
----------------------------
http://www.show-ip.org
http://php.net/manual/en/function.strpos.php