dongxu0690
2015-06-16 11:57
浏览 51
已采纳

PHP:在给定绝对路径的情况下从站点根获取路径

Maybe a dumb question: given a full path like:

C:/wamp/www/acme/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf

and given that site root is acme, how can I get the part:

/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf

in the easiest way?

图片转代码服务由CSDN问答提供 功能建议

也许是一个愚蠢的问题:给出一个完整的路径,如:

  C:/wamp/www/acme/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf 
   
 
 

并且假设站点根目录为 acme ,我该如何获得该部分:

  /archivio/subfolder/C00005/FATCLI/2014-V00011.pdf
    
 
 

以最简单的方式?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongyu9263 2015-06-16 11:59
    已采纳

    You can use explode -

    $path = 'C:/wamp/www/acme/archivio/subfolder/C00005/FATCLI/2014-V00011.pdf';
    
    $paths = explode('acme', $path);
    
    echo $paths[1];
    

    explode()

    You can variable also -

    $root = 'acme';
    $paths = explode($root, $path);
    
    点赞 打赏 评论

相关推荐 更多相似问题