Heim >Backend-Entwicklung >PHP-Tutorial >裁剪字符串有关问题
裁剪字符串问题
../user/123456/230216511.jpg
我想把前面的2个点去掉、怎么弄?
就是变成/user/123456/230216511.jpg
------解决方案--------------------
$str = '../user/123456/230216511.jpg';echo preg_replace('/^(\.){2}/', '', $str);//或者if (substr($str, 0, 2) == '..') echo substr($str, 2);<div class="clear"> </div>