php截取字符串有关问题!在线结贴
                        
                            时间:2021-07-01 10:21:17
                            帮助过:8人阅读
							                        
                     
                    
                    php截取字符串问题!在线等 在线结贴
yybb_cx.
yybb_xdf.
就像上面的字符串。我只需要_后面和.前面的字母  
比如以上两个  我需要的分别就是  cx 和 xdf   应该怎么处理?
              
                
                
                
                  
分享到:
                  
                
              ------解决方案--------------------$s=<<
yybb_cx.
yybb_xdf.
html;
preg_match_all('/_(.+?)\./s',$s,$m);
print_r($m[1]);
------解决方案--------------------preg_match('/_(.+?)\./s',$data,$m);
$a=$m[1];  //$a 就是你要的变量------解决方案--------------------不喜欢正则那就这样截取
$a = "yybb_cx.";
$a = substr(substr($a,5),0,-1);
echo $a;
------解决方案--------------------$s = 'yybb_cx.';
strtok($s, '_');
$a = strtok('.');
echo $a; //cx