Home > php教程 > php手册 > php query file extension

php query file extension

WBOY
Release: 2016-08-08 08:49:51
Original
1339 people have browsed it
<span style="color: #008080;"> 1</span> <span style="color: #008000;">//</span><span style="color: #008000;">查询文件扩展名</span>
<span style="color: #008080;"> 2</span> <span style="color: #0000ff;">function</span> extension(<span style="color: #800080;">$str</span><span style="color: #000000;">){
</span><span style="color: #008080;"> 3</span>     <span style="color: #800080;">$str</span> = <span style="color: #008080;">implode</span>("",<span style="color: #008080;">explode</span>("\\",<span style="color: #800080;">$str</span><span style="color: #000000;">));
</span><span style="color: #008080;"> 4</span>     <span style="color: #800080;">$str</span> = <span style="color: #008080;">explode</span>(".",<span style="color: #800080;">$str</span><span style="color: #000000;">);
</span><span style="color: #008080;"> 5</span>     <span style="color: #800080;">$str</span> = <span style="color: #008080;">strtolower</span>(<span style="color: #008080;">end</span>(<span style="color: #800080;">$str</span><span style="color: #000000;">));
</span><span style="color: #008080;"> 6</span>     <span style="color: #0000ff;">return</span> <span style="color: #800080;">$str</span><span style="color: #000000;">;
</span><span style="color: #008080;"> 7</span> <span style="color: #000000;">}
</span><span style="color: #008080;"> 8</span> 
<span style="color: #008080;"> 9</span> <span style="color: #800080;">$file</span> = 'D://a\b\name-Of_somefile.File.txt'<span style="color: #000000;">;
</span><span style="color: #008080;">10</span> <span style="color: #0000ff;">echo</span> extension(<span style="color: #800080;">$file</span>);
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 Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template