//这里想取备注之前的字符串,去掉括号内容
$str = "这是一个字符串 (备注)";
$location = mb_strripos($str , "(" ); //获取左括号出现的位置
$newstr = '';
if($location !== false){ //获取不到会返回false
$newstr = mb_substr($str,0,$location-1); //中文截取字符串,这里有空格,所以减一
}
var_dump($newstr);
//这里想取备注之前的字符串,去掉括号内容
$str = "这是一个字符串 (备注)";
$location = mb_strripos($str , "(" ); //获取左括号出现的位置
$newstr = '';
if($location !== false){ //获取不到会返回false
$newstr = mb_substr($str,0,$location-1); //中文截取字符串,这里有空格,所以减一
}
var_dump($newstr);