Home > Backend Development > PHP Tutorial > 分割字符串~

分割字符串~

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 13:34:54
Original
1016 people have browsed it

分割字符串求助~~!!!
有这么一坨字符串:
/xxxx/zzzz/vvvv/bbbb/default_head/user1.gif
/video/templates/templates/images/default_head/user2.gif
......
/xxxx/zzzz/vvvv/bbbb/default_head/user14.gif

我需要得到user后面 和 “.” 前面的数字啊 (如1,2,14)

------解决方案--------------------

PHP code
<?php $str='/xxxx/zzzz/vvvv/bbbb/default_head/user14.gif';
preg_match('/(\d+)\.[^.]+/',$str,$match);
echo $match[1]; <div class="clear">
                 
              
              
        
            
Copy after login
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
Switch user
From 1970-01-01 08:00:00
0
0
0
User login
From 1970-01-01 08:00:00
0
0
0
Delete user to get id
From 1970-01-01 08:00:00
0
0
0
Translate: Laravel: Get Sanctum token by user ID
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template