Home > Backend Development > PHP Tutorial > 裁剪字符串有关问题

裁剪字符串有关问题

WBOY
Release: 2016-06-13 10:04:47
Original
837 people have browsed it

裁剪字符串问题
../user/123456/230216511.jpg
我想把前面的2个点去掉、怎么弄?
就是变成/user/123456/230216511.jpg

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

PHP code
$str = '../user/123456/230216511.jpg';echo preg_replace('/^(\.){2}/', '', $str);//或者if (substr($str, 0, 2) == '..') echo substr($str, 2);<div class="clear">
                 
              
              
        
            </div>
Copy after login
Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template