strstr,可以删除指定字符前面的所有字符串,
有没有哪个函数可以删除指定字符后面的所有字符串,
是不是都要用strpos,还是正则?

解决方案 »

  1.   

    $s = '可以删除指定字符前面的所有字符串';
    $k = '面';
    echo strstr($s, $k);//面的所有字符串
    echo strtok($s, $k); //可以删除指定字符前
      

  2.   

    string strstr ( string $haystack , mixed $needle [, bool $before_needle = false ] )第三个参数:If TRUE, strstr() returns the part of the haystack before the first occurrence of the needle (excluding the needle).
      

  3.   


    输出的是echo strstr($s, $k);//面的所有字符串
    echo strtok($s, $k); //可以删
    ,我想要删除的是“面”后面的所有字符串。
      

  4.   

    echo mb_substr($s,0,mb_strpos($s,$k,0,'utf-8')+1,'utf-8');  //utf-8编码
      

  5.   

    $str
    $search
    substr($str,strpos($str,$ssearch)+1,strlen($str))
    如果是第一个$search开始截取用strpos
    如果是最后一个$search开始截取用strrpos