Home >Backend Development >PHP Tutorial >php在字符串中查找另一个字符串_php技巧

php在字符串中查找另一个字符串_php技巧

WBOY
WBOYOriginal
2016-05-17 09:34:231118browse
返回列表


中查找

>第二个字符串可以在第一个字符串的任何位置

>第一个字符串以第二个字符串开始

>第一个字符串以第二个字符串结束

>区分大小写




if(isset($string) and isset($query) and $string"" and $query""){
  if(isset($case)){
    $func = "ereg";
  }
  else{
    $func = "eregi";
  }
  switch($where){
    case "^":
      $query = "^" . $query;
      break;
    case "$":
      $query .= "$";
      break;
  }
  eval("$found = $func("$query","$string");");
  if($found){
    echo "找到!";
  }
  else{
    echo "未找到!";
  }
}
?>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn