<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <title>Snipplr</title>
    <description>Recent snippets posted on Snipplr.com</description>
    <link>https://snipplr.com/</link>
    <lastBuildDate>Tue, 09 Jun 2026 12:53:46 +0000</lastBuildDate>
    <item>
      <title>(PHP) Fastest way to validate a path with a list of extensions - Oldarney</title>
      <link>https://snipplr.com/view/24700/fastest-way-to-validate-a-path-with-a-list-of-extensions</link>
      <description>&lt;p&gt;Here is the research of running the scripts 10000 times, in milliseconds:&#13;
&#13;
preg_match('/.*\.(jpg|gif|png)\z/',substr('the image/is on/fire.jpg,-4'))&#13;
0.29-0.27&#13;
&#13;
in_array(strtolower(substr('the image/is on/fire.jpg',-3)), array('jpg','gif','png'))&#13;
0.03-0.025&#13;
&#13;
switch (strtolower(substr('the image/is on/fire.jpg',-3))){&#13;
	case 'jpg':&#13;
	case 'gif':&#13;
	case 'png':&#13;
		$ec = true;&#13;
}//use $ec for return statement&#13;
0.019-0.14&lt;/p&gt;</description>
      <pubDate>Sun, 13 Dec 2009 08:35:59 UTC</pubDate>
      <guid>https://snipplr.com/view/24700/fastest-way-to-validate-a-path-with-a-list-of-extensions</guid>
    </item>
    <item>
      <title>(PHP) Regex Extension comparer - Oldarney</title>
      <link>https://snipplr.com/view/24698/regex-extension-comparer</link>
      <description>&lt;p&gt;I whipped this up after finding that my worst fears were true, pathinfo is slow. Top that with in_array and you've got your self some heavy code. Nothing like regex to speed things up.&#13;
&#13;
This little code checks the extension of a path to see if it is a desired extension.&#13;
&#13;
EDIT: the regex engine kills any speed benefits...&lt;/p&gt;</description>
      <pubDate>Sun, 13 Dec 2009 08:02:57 UTC</pubDate>
      <guid>https://snipplr.com/view/24698/regex-extension-comparer</guid>
    </item>
  </channel>
</rss>
