您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

php 判断字符串包含指定字符

2024/11/6 4:08:30发布37次查看
下面是利用正则表达式来判断字符串包含指定字符的php代码,主要用到了ereg函数来征
//实例一
 代码如下 复制代码
    $string=i am abc;
    if (ereg (www.111cn.net, $string)) echo 'abc' is true ;                  
    if (ereg (^abc, $string)) echo '^abc' is true
;                  
    if (ereg (abc$, $string)) echo 'abc$' is true;
//实例二
代码如下 复制代码
     $string = this is a test. that is another test.;
     echo ereg_replace ( is,   was, $string).;
     echo ereg_replace ( is, is, $string).
;
     echo ereg_replace (test, test, $string);
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product