<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: PHP Function To Get A File Extension From A&#160;String</title> <atom:link href="http://davidwalsh.name/php-function-get-file-extension-string/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/php-function-get-file-extension-string</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Wed, 23 May 2012 19:56:08 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Andrew Ensley</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-32088</link> <dc:creator>Andrew Ensley</dc:creator> <pubDate>Tue, 08 May 2012 16:51:39 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-32088</guid> <description>I found this post from Google, and though &quot;wow, what a simple answer.&quot; I then read the comments suggesting alternative methods and gave those a try as well.  They all work of course, but I wanted to know what worked &lt;b&gt;*better*&lt;/b&gt;, so I benchmarked them.  The following is how long it took my server to run each method 1 million times on the string: &#039;/var/www/thisisatest.1.2.18.min.js&#039;Substr: 0.8037 seconds
Pathinfo: 1.95027 seconds
Explode: 2.35024 secondsClearly, the method you posted smoked the competition.  I will be using it.  Thank you for posting this!</description> <content:encoded><![CDATA[<p>I found this post from Google, and though &#8220;wow, what a simple answer.&#8221; I then read the comments suggesting alternative methods and gave those a try as well.  They all work of course, but I wanted to know what worked <b>*better*</b>, so I benchmarked them.  The following is how long it took my server to run each method 1 million times on the string: &#8216;/var/www/thisisatest.1.2.18.min.js&#8217;</p><p>Substr: 0.8037 seconds<br
/> Pathinfo: 1.95027 seconds<br
/> Explode: 2.35024 seconds</p><p>Clearly, the method you posted smoked the competition.  I will be using it.  Thank you for posting this!</p> ]]></content:encoded> </item> <item><title>By: Rajeev</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-30218</link> <dc:creator>Rajeev</dc:creator> <pubDate>Fri, 24 Feb 2012 09:37:22 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-30218</guid> <description>I always prefer php code functions eg.$file_extension=pathinfo($filename, PATHINFO_EXTENSION);</description> <content:encoded><![CDATA[<p>I always prefer php code functions eg.</p><p>$file_extension=pathinfo($filename, PATHINFO_EXTENSION);</p> ]]></content:encoded> </item> <item><title>By: sudhir</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-28437</link> <dc:creator>sudhir</dc:creator> <pubDate>Thu, 05 Jan 2012 06:06:24 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-28437</guid> <description>Thanks , IT is  really very user full.</description> <content:encoded><![CDATA[<p>Thanks , IT is  really very user full.</p> ]]></content:encoded> </item> <item><title>By: GotiBandhu</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-27063</link> <dc:creator>GotiBandhu</dc:creator> <pubDate>Fri, 30 Sep 2011 12:56:48 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-27063</guid> <description>Hello Everyone,
In PHP, two function are available $_Get () and $_Post () for passing values from one page to another page, this functions are used to get the values which are passed from a user-filled form (User input value form), like user registration or login form etc........................ for more details please check out the following link....
http://www.mindstick.com/Articles/7591b2ed-8eb3-4382-8e72-cd58767a7f29/?PHP $_Get FunctionThanks !!!!</description> <content:encoded><![CDATA[<p>Hello Everyone,<br
/> In PHP, two function are available $_Get () and $_Post () for passing values from one page to another page, this functions are used to get the values which are passed from a user-filled form (User input value form), like user registration or login form etc&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230;&#8230; for more details please check out the following link&#8230;.<br
/> <a
href="http://www.mindstick.com/Articles/7591b2ed-8eb3-4382-8e72-cd58767a7f29/?PHP" rel="nofollow">http://www.mindstick.com/Articles/7591b2ed-8eb3-4382-8e72-cd58767a7f29/?PHP</a> $_Get Function</p><p>Thanks !!!!</p> ]]></content:encoded> </item> <item><title>By: wael fareed</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-24985</link> <dc:creator>wael fareed</dc:creator> <pubDate>Thu, 30 Jun 2011 15:48:46 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-24985</guid> <description>// gif image uploaded
if (isset($_FILES[&#039;file&#039;])) {
$file_extension =$_FILES[&#039;file&#039;][&#039;extension&#039;] ;
$extension = substr(&quot;$file_extension&quot;, 6); // remove the image/ and the gif extension remains.
echo $extension // return gif
}</description> <content:encoded><![CDATA[<p>// gif image uploaded<br
/> if (isset($_FILES['file'])) {<br
/> $file_extension =$_FILES['file']['extension'] ;<br
/> $extension = substr(&#8220;$file_extension&#8221;, 6); // remove the image/ and the gif extension remains.<br
/> echo $extension // return gif<br
/> }</p> ]]></content:encoded> </item> <item><title>By: beauty</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-24271</link> <dc:creator>beauty</dc:creator> <pubDate>Mon, 30 May 2011 17:00:17 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-24271</guid> <description>There are many way to get file extension. For me, I use
&lt;code&gt;end(explode(&#039;.&#039;, $_FILES[&#039;fileupload&#039;][&#039;name&#039;]));&lt;/code&gt;
I think this is easy to understand code from it.</description> <content:encoded><![CDATA[<p>There are many way to get file extension. For me, I use<br
/> <code>end(explode('.', $_FILES['fileupload']['name']));</code><br
/> I think this is easy to understand code from it.</p> ]]></content:encoded> </item> <item><title>By: DaveDisaster</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-23997</link> <dc:creator>DaveDisaster</dc:creator> <pubDate>Fri, 13 May 2011 17:11:40 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-23997</guid> <description>I&#039;ve run a bunch of microtime() tests, and almost every time pathinfo() is the fastest, by a healthy margin over end/explode. substr/strrchr seems to vary somewhere in the middle.</description> <content:encoded><![CDATA[<p>I&#8217;ve run a bunch of microtime() tests, and almost every time pathinfo() is the fastest, by a healthy margin over end/explode. substr/strrchr seems to vary somewhere in the middle.</p> ]]></content:encoded> </item> <item><title>By: rafieldex</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-22077</link> <dc:creator>rafieldex</dc:creator> <pubDate>Tue, 21 Dec 2010 21:15:02 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-22077</guid> <description>Oh come on...i wrote this post quickly.function f_extension($fn){
$str=explode(‘/’,$fn);
$len=count($str);
if (strpos($str[($len-1)],&#039;.&#039;) === False) return False; // Has not .
$str2=explode(‘.’,$str[($len-1)]);
$len2=count($str2);
$ext=$str2[($len2-1)];
return $ext;
}</description> <content:encoded><![CDATA[<p>Oh come on&#8230;i wrote this post quickly.</p><p>function f_extension($fn){<br
/> $str=explode(‘/’,$fn);<br
/> $len=count($str);<br
/> if (strpos($str[($len-1)],&#8217;.') === False) return False; // Has not .<br
/> $str2=explode(‘.’,$str[($len-1)]);<br
/> $len2=count($str2);<br
/> $ext=$str2[($len2-1)];<br
/> return $ext;<br
/> }</p> ]]></content:encoded> </item> <item><title>By: sumit</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-17296</link> <dc:creator>sumit</dc:creator> <pubDate>Tue, 27 Apr 2010 13:19:13 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-17296</guid> <description>end(explode(‘.’, “filename.ext));,
explain how does it work</description> <content:encoded><![CDATA[<p>end(explode(‘.’, “filename.ext));,<br
/> explain how does it work</p> ]]></content:encoded> </item> <item><title>By: sumit</title><link>http://davidwalsh.name/php-function-get-file-extension-string#comment-17295</link> <dc:creator>sumit</dc:creator> <pubDate>Tue, 27 Apr 2010 13:17:30 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-17295</guid> <description>@crivion:  please explain it with example</description> <content:encoded><![CDATA[<p>@crivion:  please explain it with example</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 3/7 queries in 0.008 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-23 16:25:15 -->
