时间:2021-07-01 10:21:17 帮助过:26人阅读
$email = 'name@example.com' ;
$domain = strstr ( $email , '@' );
echo $domain ; // 打印 @example.com
$user = strstr ( $email , '@' , true ); // 从 PHP 5.3.0 起
echo $user ; // 打印 name
$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; }