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

裁剪字符串有关问题

WBOY
WBOYOriginal
2016-06-13 10:04:47831browse

裁剪字符串问题
../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>
Statement:
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