<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></title> 
<link>https://jackxiang.com/index.php</link> 
<description><![CDATA[赢在IT，Playin' with IT,Focus on Killer Application,Marketing Meets Technology.]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[向东博客 专注WEB应用 构架之美 --- 构架之美，在于尽态极妍 | 应用之美，在于药到病除]]></copyright>
<item>
<link>https://jackxiang.com/post//</link>
<title><![CDATA[[实践OK]php去文件名后缀，PHP从文件名(filename)中删除扩展名(extension)的三种方法。]]></title> 
<author>jack &lt;xdy108@126.com&gt;</author>
<category><![CDATA[Php/Js/Shell/Go]]></category>
<pubDate>Tue, 02 Jul 2019 08:48:49 +0000</pubDate> 
<guid>https://jackxiang.com/post//</guid> 
<description>
<![CDATA[ 
	<textarea name="code" class="php" rows="15" cols="100">
php -a
php &gt; $name=&quot;k8s.yml&quot;;
php &gt; $without_extension = pathinfo($name, PATHINFO_FILENAME);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
php &gt; echo $without_extension;
k8s
</textarea><br/><br/> echo strrpos(&quot;jack.txt&quot;,&quot;.&quot;);<br/>4<br/><br/>如果你有一个文件名，你需要从PHP中删除扩展名(extension)，有很多方法可以做到这一点。这里有三种方法。<br/><br/><br/>substr(strrchr($file, &#039;.&#039;), 1);<br/><br/><a href="https://www.cnblogs.com/justdoityangbo/p/11113579.html" target="_blank">https://www.cnblogs.com/justdoityangbo/p/11113579.html</a><br/><br/>使用pathinfo()函数<br/><br/>pathinfo()函数返回一个包含dirname，basename，extension和filename的数组。或者，您可以传递一个PATHINFO_常量，并返回完整文件名的那一部分：<br/><br/>$filename =&#039;filename.html&#039;;<br/>$without_extension = pathinfo($filename, PATHINFO_FILENAME);<br/>如果文件名包含完整路径，则仅返回不带扩展名的文件名。<br/><br/><br/>使用basename()函数<br/><br/>如果扩展名是已知的并且对于所有文件名是相同的，则可以将第二个可选参数传递给basename()以告诉它从文件名中删除该扩展名：<br/><br/>$filename =&#039;filename.html&#039;;<br/>$without_extension = basename($filename，&#039;.html&#039;);<br/>如果文件名包含完整路径，则仅返回不带扩展名的文件名。<br/><br/>使用substr和strrpos<br/><br/>$filename =&#039;filename.html&#039;;<br/>$without_extension = substr($filename, 0, strrpos($filename, &quot;.&quot;));<br/>如果文件名包含完整路径，则返回没有扩展名的完整路径和文件名。您可以使用basename()来删除路径，例如：<br/><br/>basename(substr($filename, 0, strrpos($filename, &quot;.&quot;)));<br/>尽管它比使用pathinfo慢。<br/><br/>速度比较<br/><br/>使用PHP 5.4在Mac上以10,000,000次循环运行其中的每一个：<br/><br/>pathinfo：10.13秒<br/>basename：7.87秒<br/>substr / strrpos：6.05秒<br/>basename(substr / strrpos)：11.98秒<br/>如果文件名不包含完整路径，或者如果它不重要，那么substr / strrpos选项似乎是最快的。<br/><br/>如果文件名包含路径并且您不想要路径但确实知道要删除的扩展名是什么，那么basename似乎是最快的。<br/><br/>如果文件名包含路径，则不需要路径，也不知道扩展名是什么，那么使用pathinfo()选项。<br/><br/>结论<br/><br/>还有很多其他方法可以做到这一点，有些可能会更快。在很多情况下，速度可能并不那么重要（运行pathinfo的10秒钟毕竟是10万次）。这篇文章的目的是展示一些用PHP从文件名中删除扩展名的方法。<br/><br/><br/>来自：http://www.webkaka.com/tutorial/php/2019/050857/<br/>
]]>
</description>
</item><item>
<link>https://jackxiang.com/post//#blogcomment</link>
<title><![CDATA[[评论] [实践OK]php去文件名后缀，PHP从文件名(filename)中删除扩展名(extension)的三种方法。]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://jackxiang.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>