时间:2021-07-01 10:21:17 帮助过:6人阅读
$str='aaaaa,bbbbbbb,ccccc';
if(strpos($str,',')){
preg_match('/([^,]+?),/i',$str,$match);
}
print_r($match[1]);
/*
aaaaa
*/
$s = 'aaaaa,bbbbbbb,ccccc';
echo strtok($s, ',');
$string = '111a,111';
$flag = strpos($string, ',');
if($flag !== FALSE){
$arr = explode(',', $string);
echo $arr[0];
}else{
echo $string;
}