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

2010-09-25 15:19:41 by 【6yang】, 63 visits, 收藏 | 返回

//实例一

    $string="i am abc";
    if (ereg ("www.zzarea.com", $string)) echo "'abc' is true <p>";                  
    if (ereg ("^abc", $string)) echo "'^abc' is true <p>";                  
    if (ereg ("abc$", $string)) echo "'abc$' is true";//实例二

 

     $string = "this is a test. that is another test.";
     echo ereg_replace (" is", "  was", $string)."<p>";
     echo ereg_replace (" is", "<b> is</b>", $string)."<p>";
     echo ereg_replace ("test", "<a href=http://www.zzarea.com>test</a>", $string);

分享到:
share

    图片原图

    loading

    loading