<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Darren&#039;s Desk</title>
	<atom:link href="http://darrenwestall.net/blog/feed/" rel="self" type="application/rss+xml" />
	<link>http://darrenwestall.net/blog</link>
	<description>PHP, PERL, MySql and general coding discussions</description>
	<lastBuildDate>Wed, 20 Jan 2010 17:48:28 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.4</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>How to tell if somebody is signed in on AIM</title>
		<link>http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/</link>
		<comments>http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 17:48:28 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/blog/?p=53</guid>
		<description><![CDATA[Whilst writing an AIM bot, I needed a way to check if a user was online &#8211; after reading AOL&#8217;s API I discovered this:
http://big.oscar.aol.com/$aim?on_url=true&#038;off_url=false
replace $aim with the aim address you are querying &#8211; if they are online you will be taken here:
http://big.oscar.aol.com/true
if not:
http://big.oscar.aol.com/false


Bookmark It



















Hide Sites



$$('div.d53').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); ]]></description>
			<content:encoded><![CDATA[<p>Whilst writing an AIM bot, I needed a way to check if a user was online &#8211; after reading AOL&#8217;s API I discovered this:</p>
<p>http://big.oscar.aol.com/$aim?on_url=true&#038;off_url=false</p>
<p>replace $aim with the aim address you are querying &#8211; if they are online you will be taken here:</p>
<p>http://big.oscar.aol.com/true</p>
<p>if not:</p>
<p>http://big.oscar.aol.com/false</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d53').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d53" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;submitHeadline=How+to+tell+if+somebody+is+signed+in+on+AIM&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;title=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;title=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;title=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;bm_description=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;T=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;title=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;title=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+How+to+tell+if+somebody+is+signed+in+on+AIM+@+http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/&amp;t=How+to+tell+if+somebody+is+signed+in+on+AIM" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d53').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d53').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2010/01/20/how-to-tell-if-somebody-is-signed-in-on-aim/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add a stylesheet on the fly with javascript</title>
		<link>http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/</link>
		<comments>http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/#comments</comments>
		<pubDate>Wed, 20 Jan 2010 09:12:03 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[dom]]></category>
		<category><![CDATA[on the fly]]></category>
		<category><![CDATA[stylesheet]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/blog/?p=51</guid>
		<description><![CDATA[You may notice ive been dabbling in javascript more recently. As part of a project I need to insert a stylesheet through javascript, my first attempt lead to me being success; only in firefox. I decided to insert the stylesheet in the body of the HTML by updating the InnerHtml of a div i knew [...]]]></description>
			<content:encoded><![CDATA[<p>You may notice ive been dabbling in javascript more recently. As part of a project I need to insert a stylesheet through javascript, my first attempt lead to me being success; <strong>only in firefox.</strong> I decided to insert the stylesheet in the body of the HTML by updating the InnerHtml of a div i knew existed. This worked a treat in firefox but notta thing in other (probably right) browsers. </p>
<p>I set about doing it the right way and this is what I came with:<br />
<code>function add_stylesheet(){<br />
    if(document.createStyleSheet) {<br />
        document.createStyleSheet('http://counter.adcourier.com/share/css/share.css');<br />
    } else {<br />
        var styles = "@import url('http://counter.adcourier.com/share/css/share.css');";<br />
        var newSS=document.createElement('link');<br />
        newSS.rel='stylesheet';<br />
        newSS.href='data:text/css,'+escape(styles);<br />
        document.getElementsByTagName("head")[0].appendChild(newSS);<br />
    }<br />
}</code></p>
<p>Cross browser and exactly what I wanted.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d51').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d51" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;submitHeadline=Add+a+stylesheet+on+the+fly+with+javascript&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;title=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;title=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;title=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;bm_description=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;T=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;title=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;title=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Add+a+stylesheet+on+the+fly+with+javascript+@+http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/&amp;t=Add+a+stylesheet+on+the+fly+with+javascript" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d51').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d51').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2010/01/20/add-a-stylesheet-on-the-fly-with-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Automatic bookmark script in javascript</title>
		<link>http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/</link>
		<comments>http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/#comments</comments>
		<pubDate>Mon, 18 Jan 2010 13:38:00 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[bookmark]]></category>
		<category><![CDATA[favourite]]></category>
		<category><![CDATA[firefox]]></category>
		<category><![CDATA[internet explorer]]></category>
		<category><![CDATA[opera]]></category>
		<category><![CDATA[safari]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/blog/?p=47</guid>
		<description><![CDATA[After googling, yahooing and scratching my head &#8211; ive now realised that automatic booking in browsers such as Chrome and Safari (including the iphone) simply isn&#8217;t possible. However I did find a useful script that takes care of IE, Firefox and Opera &#8211; whilst displaying a &#8220;helpful&#8221; message to others.
function bookmarksite(){
    var [...]]]></description>
			<content:encoded><![CDATA[<p>After googling, yahooing and scratching my head &#8211; ive now realised that automatic booking in browsers such as Chrome and Safari (including the iphone) simply isn&#8217;t possible. However I did find a useful script that takes care of IE, Firefox and Opera &#8211; whilst displaying a &#8220;helpful&#8221; message to others.</p>
<p><code>function bookmarksite(){<br />
    var title = top.document.title;<br />
    var url = document.location.href;<br />
    if (window.sidebar){ // firefox<br />
        window.sidebar.addPanel(title, url, "");<br />
    }else if(window.opera &amp;&amp; window.print){ // opera<br />
        var elem = document.createElement('a');<br />
        elem.setAttribute('href',url);<br />
        elem.setAttribute('title',title);<br />
        elem.setAttribute('rel','sidebar');<br />
        elem.click();<br />
    }else if(document.all){ // ie<br />
        window.external.AddFavorite(url, title);<br />
    } else{<br />
         alert("Sorry, we do not support automatic bookmarking for your browser at this time.");<br />
    }<br />
}</code></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d47').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d47" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;submitHeadline=Automatic+bookmark+script+in+javascript&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;title=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;title=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;title=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;bm_description=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;T=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;title=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;title=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Automatic+bookmark+script+in+javascript+@+http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/&amp;t=Automatic+bookmark+script+in+javascript" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d47').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d47').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2010/01/18/automatic-bookmark-script-in-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Create a unique comma separated list from an array.</title>
		<link>http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/</link>
		<comments>http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/#comments</comments>
		<pubDate>Tue, 22 Sep 2009 08:16:05 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PERL]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/blog/?p=42</guid>
		<description><![CDATA[Hi There,
Some quick PERL today   &#8211; Recently I was working with someone who wanted to produce a comma separated list from an array element &#8211; the catch was they only wanted unique values. There attempt was as follows:
my ($val1,$val2,$val3) = @_;
my $return;
$return .= $val1;
$return .= ','.$val2 if ($val2 &#38;&#38; ($val2 ne $val1));
$return .= [...]]]></description>
			<content:encoded><![CDATA[<p>Hi There,</p>
<p>Some quick PERL today <img src='http://darrenwestall.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  &#8211; Recently I was working with someone who wanted to produce a comma separated list from an array element &#8211; the catch was they only wanted unique values. There attempt was as follows:</p>
<p><code>my ($val1,$val2,$val3) = @_;<br />
my $return;<br />
$return .= $val1;<br />
$return .= ','.$val2 if ($val2 &amp;&amp; ($val2 ne $val1));<br />
$return .= ','.$val3 if ($val3 &amp;&amp; ($val3 ne $val1) &amp;&amp; ($val3 ne $val2));<br />
return $return;</code></p>
<p>Okay, so that does the job. Is it pretty? no. Is it efficient? Hell no.</p>
<p>So, heres how I propose it should be done:</p>
<p><code>my @list = @_;<br />
my %seen = ();<br />
@list = grep { $_ &amp;&amp; !$seen{$_}++ }@list;<br />
return join(',',@list);</code></p>
<p>Beautiful, and only 2 lines of code. <img src='http://darrenwestall.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> . If any of you have a better of way of doing this, please feel free to comment below.</p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d42').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d42" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;submitHeadline=Create+a+unique+comma+separated+list+from+an+array.&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;title=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;title=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;title=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;bm_description=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;T=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;title=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;title=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Create+a+unique+comma+separated+list+from+an+array.+@+http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/&amp;t=Create+a+unique+comma+separated+list+from+an+array." rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d42').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d42').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2009/09/22/create-a-unique-comma-separated-list-from-an-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Run PHP from a .html extension</title>
		<link>http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/</link>
		<comments>http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/#comments</comments>
		<pubDate>Mon, 21 Sep 2009 15:19:01 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[htaccess]]></category>
		<category><![CDATA[html]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/blog/?p=37</guid>
		<description><![CDATA[I recently had an odd request, they wanted their site to appear as HTML but run PHP; my first thought was why? but, if thats what they want, thats what they get.   
It turned out to be a very simple task. If you open up your .htaccess file and add the following line:
 [...]]]></description>
			<content:encoded><![CDATA[<p>I recently had an odd request, they wanted their site to appear as HTML but run PHP; my first thought was why? but, if thats what they want, thats what they get.   </p>
<p>It turned out to be a <strong>very</strong> simple task. If you open up your .htaccess file and add the following line:</p>
<p><code> AddType application/x-httpd-php .html</code></p>
<p>.html will execute as PHP!</p>
<p>Job done. <img src='http://darrenwestall.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d37').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d37" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;submitHeadline=Run+PHP+from+a+.html+extension&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;title=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;title=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;title=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;bm_description=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;T=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;title=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;title=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Run+PHP+from+a+.html+extension+@+http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/&amp;t=Run+PHP+from+a+.html+extension" rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d37').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d37').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2009/09/21/run-php-from-a-html-extension/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Randomize array whilst keeping the keys in tact..</title>
		<link>http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/</link>
		<comments>http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/#comments</comments>
		<pubDate>Fri, 08 May 2009 12:36:02 +0000</pubDate>
		<dc:creator>Darren</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[keys stay the same]]></category>
		<category><![CDATA[randomize]]></category>

		<guid isPermaLink="false">http://darrenwestall.net/?p=25</guid>
		<description><![CDATA[I had a problem recently &#8211; I needed to randomize an array &#8211; of course I could have used the PHP function array_rand  however, this overwrote the existing keys with numbers &#8211; not good! as I need to use those keys as part of my display &#8211; okay, not best practice but i&#8217;d set [...]]]></description>
			<content:encoded><![CDATA[<p>I had a problem recently &#8211; I needed to randomize an array &#8211; of course I could have used the PHP function <a href="http://uk2.php.net/manual/en/function.array-rand.php">array_rand </a> however, this overwrote the existing keys with numbers &#8211; not good! as I need to use those keys as part of my display &#8211; okay, not best practice but i&#8217;d set it up this way thus far, why should I change it? Therefore I discovered a function that allowed me to do exactly what I needed, it randomizes the array whilst keeping the existing keys <img src='http://darrenwestall.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
<p><code>function array_rand_keys($array, $limit = 1) {<br />
    $count = @count($array)-1;</p>
<p>    if ($limit == 0 || !is_array($array) || $limit &gt; $count) return array();<br />
    if ($count == 1) return $array;</p>
<p>    for ($x = 0; $x &lt; $limit; $x++) {<br />
        $rand = rand(0, $count);</p>
<p>        while (isset($rands[$rand])) $rand = rand(0, $count);</p>
<p>        $rands[$rand] = $rand;<br />
    }</p>
<p>    $return = array();<br />
    $curr = current($rands);</p>
<p>    while (count($return) != $limit) {<br />
        $cur = 0;</p>
<p>        foreach ($array as $key =&gt; $val) {<br />
            if ($cur == $curr) {<br />
                $return[$key] = $val;</p>
<p>                $curr = next($rands);<br />
                continue 2;<br />
            } else {<br />
                $cur++;<br />
            }<br />
        }<br />
    }</p>
<p>    return $return;<br />
}</code></p>
<!-- Social Bookmarks BEGIN -->
<div class="social_bookmark">
<a title="Click me to see the sites." href="#" onclick="$$('div.d25').each( function(e) { e.visualEffect('slide_down',{duration:2.5}) }); return false;"><strong><em>Bookmark It</em></strong></a>
<br />
<div class="d25" style="overflow:hidden">
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://buzz.yahoo.com/submit?submitUrl=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;submitHeadline=Randomize+array+whilst+keeping+the+keys+in+tact..&amp;submitSummary=" rel="nofollow" title="Add to&nbsp;Buzz"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/buzz.png" title="Add to&nbsp;Buzz" alt="Add to&nbsp;Buzz" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://del.icio.us/post?url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;title=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Del.icio.us"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/delicious.png" title="Add to&nbsp;Del.icio.us" alt="Add to&nbsp;Del.icio.us" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://digg.com/submit?phase=2&amp;url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;title=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;digg"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/digg.png" title="Add to&nbsp;digg" alt="Add to&nbsp;digg" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.facebook.com/sharer.php?u=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/" rel="nofollow" title="Add to&nbsp;Facebook"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/facebook.png" title="Add to&nbsp;Facebook" alt="Add to&nbsp;Facebook" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.google.com/bookmarks/mark?op=edit&amp;output=popup&amp;bkmk=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;title=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Google Bookmarks"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/google.png" title="Add to&nbsp;Google Bookmarks" alt="Add to&nbsp;Google Bookmarks" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.mister-wong.com/index.php?action=addurl&amp;bm_url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;bm_description=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Mister Wong"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/misterwong.png" title="Add to&nbsp;Mister Wong" alt="Add to&nbsp;Mister Wong" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.netscape.com/submit/?U=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;T=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Netscape"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/netscape.png" title="Add to&nbsp;Netscape" alt="Add to&nbsp;Netscape" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://reddit.com/submit?url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;title=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;reddit"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/reddit.png" title="Add to&nbsp;reddit" alt="Add to&nbsp;reddit" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.stumbleupon.com/submit.php?url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;title=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Stumble Upon"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/stumbleupon.png" title="Add to&nbsp;Stumble Upon" alt="Add to&nbsp;Stumble Upon" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://www.technorati.com/faves?add=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/" rel="nofollow" title="Add to&nbsp;Technorati"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/technorati.png" title="Add to&nbsp;Technorati" alt="Add to&nbsp;Technorati" /></a>
<br />
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://tipd.com/submit.php?url=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/" rel="nofollow" title="Add to&nbsp;Tip'd"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/tipd.png" title="Add to&nbsp;Tip'd" alt="Add to&nbsp;Tip'd" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://twitter.com/home/?status=Check+out+Randomize+array+whilst+keeping+the+keys+in+tact..+@+http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/" rel="nofollow" title="Add to&nbsp;Twitter"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/twitter.png" title="Add to&nbsp;Twitter" alt="Add to&nbsp;Twitter" /></a>
<a onclick="window.open(this.href, '_blank', 'scrollbars=yes,menubar=no,height=600,width=750,resizable=yes,toolbar=no,location=no,status=no'); return false;" href="http://myweb2.search.yahoo.com/myresults/bookmarklet?u=http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/&amp;t=Randomize+array+whilst+keeping+the+keys+in+tact.." rel="nofollow" title="Add to&nbsp;Yahoo My Web"><img class="social_img" src="http://darrenwestall.net/blog/wp-content/plugins/social-bookmarks/images/yahoo.png" title="Add to&nbsp;Yahoo My Web" alt="Add to&nbsp;Yahoo My Web" /></a>
<br />
<a style="font-size:90%;text-align: right; " title="Click me to hide the sites." href="#" onclick="$$('div.d25').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); return false;">Hide Sites</a>
</div>
</div>
<!-- Social Bookmarks END -->
<script type="text/javascript">$$('div.d25').each( function(e) { e.visualEffect('slide_up',{duration:0.5}) }); </script>]]></content:encoded>
			<wfw:commentRss>http://darrenwestall.net/blog/2009/05/08/randomize-array-whilst-keeping-the-keys-in-tact/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>
