php字符串截取解决方法

WBOY
Release: 2016-06-13 13:17:53
Original
810 people have browsed it

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>
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