Home >Backend Development >PHP Tutorial >php字符串截取解决方法

php字符串截取解决方法

WBOY
WBOYOriginal
2016-06-13 10:38:22994browse

php字符串截取
./upload/
./upload/
./upload/banear
./upload/第一期
./upload/第二期
怎么把./upload/这个截取掉,只要他后面的东西

------解决方案--------------------
用这个:$str=preg_replace('#\./upload/#s','',$str); 来匹配试试
------解决方案--------------------
$strarr=explode("upload/",$str);
echo $strarr[1];
------解决方案--------------------

PHP code
$handle = opendir('../upload/');$arr = array();$file_arr=array();while($file = readdir($handle)){$newpath="../upload/".$file;if(is_dir($newpath)){    $arr[] = $newpath ;    $file_arr[]=$file;}}foreach($file_arr as $key=>$val){    echo $val.'<br>';    }<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