手机
当前位置:查字典教程网 >编程开发 >php教程 >php在字符串中查找另一个字符串
php在字符串中查找另一个字符串
摘要:返回列表

<a href="./">返回列表</a><br>

<form action="<?echo $PHP_SELF;?>" method="post">

在<input type="text" name="string" value="<?echo $string;?>">中查找<input type="text" name="query" value="<?echo $query;?>"><br>

<input type="radio" name="where" value="" <?if(!isset($where) or $where=="") echo "checked";?>>第二个字符串可以在第一个字符串的任何位置<br>

<input type="radio" name="where" value="^" <?if(isset($where) and $where=="^") echo "checked";?>>第一个字符串以第二个字符串开始<br>

<input type="radio" name="where" value="$" <?if(isset($where) and $where=="$") echo "checked";?>>第一个字符串以第二个字符串结束<br>

<input type="checkbox" name="case" value="case" <?if(isset($case)) echo "checked";?>>区分大小写<br>

<input type="submit" value="查询">

</form>

<?

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

}

}

?>

</body>

【php在字符串中查找另一个字符串】相关文章:

PHP中preg_match函数正则匹配的字符串长度问题

php截取指定2个字符之间字符串的方法

php按单词截取字符串的方法

php三元运算符知识汇总

php循环table实现一行两列显示的方法

php替换字符串中间字符为省略号的方法

PHP中的一些常用函数收集

php比较相似字符串的方法

php实现比较两个字符串日期大小的方法

PHP加密解密字符串汇总

精品推荐
分类导航