<?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/"
		>
<channel>
	<title>Comments on: Giving an Uploaded File a Unique Name in PHP</title>
	<atom:link href="http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/</link>
	<description>presented by Site Potion</description>
	<lastBuildDate>Thu, 03 Jun 2010 12:34:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Stankiewicz</title>
		<link>http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/comment-page-1/#comment-57196</link>
		<dc:creator>Stankiewicz</dc:creator>
		<pubDate>Fri, 19 Dec 2008 15:22:02 +0000</pubDate>
		<guid isPermaLink="false">http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/#comment-57196</guid>
		<description>Great function!</description>
		<content:encoded><![CDATA[<p>Great function!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Clay</title>
		<link>http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/comment-page-1/#comment-36755</link>
		<dc:creator>Clay</dc:creator>
		<pubDate>Wed, 23 Jan 2008 01:02:49 +0000</pubDate>
		<guid isPermaLink="false">http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/#comment-36755</guid>
		<description>@Noah: Good upgrade!</description>
		<content:encoded><![CDATA[<p>@Noah: Good upgrade!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Noah</title>
		<link>http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/comment-page-1/#comment-36754</link>
		<dc:creator>Noah</dc:creator>
		<pubDate>Thu, 10 Jan 2008 19:09:40 +0000</pubDate>
		<guid isPermaLink="false">http://www.indywebshop.com/bestpractices/2008/01/10/giving-an-uploaded-file-a-unique-name-in-php/#comment-36754</guid>
		<description>You know you&#039;re a nerd when this kind of thing is actually fun.

I&#039;m not always the best at optimizing code, but I do love the challenge of trying to figure out how to make code do what you want. So, here&#039;s my shot at it.

Replace this line:
$fulldest = str_replace(”.”,”$i.”,$originaldest);

With these two lines:
$ext = strrchr($originaldest, &quot;.&quot;);
$fulldest = str_replace($ext,$i.$ext,$originaldest);

You could do it in one line, but then you&#039;d have to run the strrchr function twice. The first line looks for the last period in the string and returns the period everything after it (which I assume is always the file extension).

The second line uses the first line&#039;s result to search and replace just the file extension and slap the integer variable in front of it. Thus avoiding the &quot;my1.precious1.file1.jpg&quot; problem.

Here is my reference: http://us.php.net/manual/en/function.strrchr.php (I&#039;ve learned so much from php.net)

Thanks for making me think! :) Your snippet will likely come in handy.</description>
		<content:encoded><![CDATA[<p>You know you&#8217;re a nerd when this kind of thing is actually fun.</p>
<p>I&#8217;m not always the best at optimizing code, but I do love the challenge of trying to figure out how to make code do what you want. So, here&#8217;s my shot at it.</p>
<p>Replace this line:<br />
$fulldest = str_replace(”.”,”$i.”,$originaldest);</p>
<p>With these two lines:<br />
$ext = strrchr($originaldest, &#8220;.&#8221;);<br />
$fulldest = str_replace($ext,$i.$ext,$originaldest);</p>
<p>You could do it in one line, but then you&#8217;d have to run the strrchr function twice. The first line looks for the last period in the string and returns the period everything after it (which I assume is always the file extension).</p>
<p>The second line uses the first line&#8217;s result to search and replace just the file extension and slap the integer variable in front of it. Thus avoiding the &#8220;my1.precious1.file1.jpg&#8221; problem.</p>
<p>Here is my reference: <a href="http://us.php.net/manual/en/function.strrchr.php" rel="nofollow">http://us.php.net/manual/en/function.strrchr.php</a> (I&#8217;ve learned so much from php.net)</p>
<p>Thanks for making me think! <img src='http://www.indywebshop.com/bestpractices/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Your snippet will likely come in handy.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
