<?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>Thu, 09 Feb 2012 15:40:33 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3</generator> <item><title>By: sudhir</title><link>http://davidwalsh.name/php-function-get-file-extension-string/comment-page-1#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-page-1#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-page-1#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-page-1#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-page-1#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-page-1#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-page-1#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-page-1#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> <item><title>By: Gabriel</title><link>http://davidwalsh.name/php-function-get-file-extension-string/comment-page-1#comment-16311</link> <dc:creator>Gabriel</dc:creator> <pubDate>Tue, 02 Mar 2010 19:23:19 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-16311</guid> <description>Thanks for sharing !</description> <content:encoded><![CDATA[<p>Thanks for sharing !</p> ]]></content:encoded> </item> <item><title>By: Isaac Van Name</title><link>http://davidwalsh.name/php-function-get-file-extension-string/comment-page-1#comment-15094</link> <dc:creator>Isaac Van Name</dc:creator> <pubDate>Thu, 07 Jan 2010 14:51:42 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/php-function-get-file-extension-string/#comment-15094</guid> <description>@Jorge: Either way works, and it just ends up being a matter of preference. You have to consider how this function will usually be used on a web application; it will be grabbing the extension and making sure it&#039;s an allowed extension for upload. Thus, the explode method would return something that doesn&#039;t match a valid extension (like your README example), and the file upload would get declined.If you&#039;re building a file explorer on the web, sure, use pathinfo(); that&#039;s common sense. If you&#039;re building a web app that takes uploads, then I can&#039;t imagine the explode method would not be faster than pathinfo.</description> <content:encoded><![CDATA[<p>@Jorge: Either way works, and it just ends up being a matter of preference. You have to consider how this function will usually be used on a web application; it will be grabbing the extension and making sure it&#8217;s an allowed extension for upload. Thus, the explode method would return something that doesn&#8217;t match a valid extension (like your README example), and the file upload would get declined.</p><p>If you&#8217;re building a file explorer on the web, sure, use pathinfo(); that&#8217;s common sense. If you&#8217;re building a web app that takes uploads, then I can&#8217;t imagine the explode method would not be faster than pathinfo.</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 1/18 queries in 0.018 seconds using disk: basic
Object Caching 865/868 objects using disk: basic

Served from: davidwalsh.name @ 2012-02-09 11:36:57 -->
