欢迎来到福编程网,本站提供各种互联网专业知识!

php在字符串中查找另一个字符串

发布时间:2008-11-19 作者: 来源:转载
在php下实现从指定的字符串中搜索字符串
返回列表



中查找


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


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


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


>区分大小写




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 "未找到!";
}
}
?>

相关推荐