<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
<channel>
<title>Snipplr - Oldarney</title>
<link>http://snipplr.com/users/Oldarney</link>
<description>Recent snippets posted on Snipplr.com</description>
<language>en-us</language>
<pubDate>Sun, 19 May 2013 12:08:57 GMT</pubDate>
<item>
<title>(PHP) Fastest way to validate a path with a list of extensions</title>
<link>http://snipplr.com/view/24700/fastest-way-to-validate-a-path-with-a-list-of-extensions/</link>
<description><![CDATA[ <p>Here is the research of running the scripts 10000 times, in milliseconds:

preg_match('/.*\.(jpg|gif|png)\z/',substr('the image/is on/fire.jpg,-4'))
0.29-0.27

in_array(strtolower(substr('the image/is on/fire.jpg',-3)), array('jpg','gif','png'))
0.03-0.025

switch (strtolower(substr('the image/is on/fire.jpg',-3))){
	case 'jpg':
	case 'gif':
	case 'png':
		$ec = true;
}//use $ec for return statement
0.019-0.14</p> ]]></description>
<pubDate>Sun, 13 Dec 2009 08:35:59 GMT</pubDate>
<guid>http://snipplr.com/view/24700/fastest-way-to-validate-a-path-with-a-list-of-extensions/</guid>
</item>
<item>
<title>(PHP) Regex Extension comparer</title>
<link>http://snipplr.com/view/24698/regex-extension-comparer/</link>
<description><![CDATA[ <p>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.

This little code checks the extension of a path to see if it is a desired extension.

EDIT: the regex engine kills any speed benefits...</p> ]]></description>
<pubDate>Sun, 13 Dec 2009 08:02:57 GMT</pubDate>
<guid>http://snipplr.com/view/24698/regex-extension-comparer/</guid>
</item>
</channel>
</rss>