<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Magp.ie &#187; php</title>
	<atom:link href="http://magp.ie/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://magp.ie</link>
	<description>A nest for the random, shiny, online tidbits I stumble across...</description>
	<lastBuildDate>Tue, 31 Jan 2012 19:01:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='magp.ie' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://0.gravatar.com/blavatar/061e340c5da13b5a41ae8016bee03aa8?s=96&#038;d=http%3A%2F%2Fs2.wp.com%2Fi%2Fbuttonw-com.png</url>
		<title>Magp.ie &#187; php</title>
		<link>http://magp.ie</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://magp.ie/osd.xml" title="Magp.ie" />
	<atom:link rel='hub' href='http://magp.ie/?pushpress=hub'/>
		<item>
		<title>HTML5 Data attributes in HTML and jQuery</title>
		<link>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/</link>
		<comments>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/#comments</comments>
		<pubDate>Tue, 29 Nov 2011 18:18:41 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Guides]]></category>
		<category><![CDATA[data attribute]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[json]]></category>
		<category><![CDATA[json_encode]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=667</guid>
		<description><![CDATA[When writing javascript, it is often necessary to include metadata in the HTML markup, to help define some element or behaviour. There are common options available. You can use hidden inputs and/or standard attributes like class or title to store &#8230; <a href="http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=667&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When writing javascript, it is often necessary to include metadata in the HTML markup, to help define some element or behaviour. There are common options available. You can use hidden inputs and/or standard attributes like <code>class</code> or <code>title</code> to store this metadata. However with HTML5&#8242;s data attribute, storing and parsing this data has become a whole lot easier and cleaner.</p>
<p>The syntax is straightforward. Any attribute prefixed with <code>data-</code> will be treated as data storage.</p>
<p><pre class="brush: xml;">&lt;div class=&quot;test&quot; data-foo=&quot;bar&quot;&gt;&lt;/div&gt;</pre></p>
<p>jQuery accesses this data like so&#8230;<br />
<pre class="brush: jscript;">var data = $( 'div.test' ).data( 'foo' ); // returns bar</pre></p>
<p>Support for the data attribute has been added since jQuery <a href="http://blog.jquery.com/2010/10/16/jquery-143-released/" title="version 1.4.3" target="_blank">version 1.4.3</a>. jQuery&#8217;s implementation is smart enough that it can parse the attribute easily and even determine the correct data type used.</p>
<p>What I have found really useful is the fact that the jQuery can parse JSON syntax and return a JSON object. This makes passing data in PHP trivial, using the <a href="http://php.net/manual/en/function.json-encode.php" title="json_encode" target="_blank">json_encode</a> method. We also need to use <a href="http://php.net/manual/en/function.htmlspecialchars.php" title="Escape quotes" target="_blank">htmlspecialchars</a> method to escape or convert any quotes in the JSON string.<br />
<pre class="brush: php;">
&lt;?php  
$test = array( 'row' =&gt; 1, 'col' =&gt; 6, 'color' =&gt; 'pink' ); //create array of data you want to pass to jquery
$test = json_encode( $test ); //convert array to a JSON string
$test = htmlspecialchars( $test, ENT_QUOTES ); //convert any quotes into HTML entities so JSON string behaves as a proper HTML attribute.
?&gt;
&lt;div class=&quot;test&quot; data-complex=&quot;&lt;?php echo $test ; ?&gt;&quot;&gt;&lt;/div&gt;</pre></p>
<p>The jQuery parses the JSON string like so&#8230;<br />
<pre class="brush: jscript;">var test = $( 'div.test' ).data( 'complex' ); // returns JSON Object

console.log( test.color ); // outputs pink!</pre></p>
<p>Important to note that this method is also backward compatible with older browsers, so there is no excuse not to give it a go!</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a>, <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/data-attribute/'>data attribute</a>, <a href='http://magp.ie/tag/html5/'>html5</a>, <a href='http://magp.ie/tag/jquery/'>jQuery</a>, <a href='http://magp.ie/tag/json/'>json</a>, <a href='http://magp.ie/tag/json_encode/'>json_encode</a>, <a href='http://magp.ie/tag/php/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/667/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/667/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/667/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=667&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/11/29/html5-data-attributes-in-html-and-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Filter IP addresses with PHP</title>
		<link>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/</link>
		<comments>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/#comments</comments>
		<pubDate>Thu, 01 Sep 2011 19:33:47 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[blacklist]]></category>
		<category><![CDATA[filter]]></category>
		<category><![CDATA[IP address]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[whitelist]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=642</guid>
		<description><![CDATA[You may at some stage want to filter an online service based on IP address. In other words, you may want to block or grant access to a request based on their IP address. This can be handled in PHP &#8230; <a href="http://magp.ie/2011/09/01/filter-ip-addresses-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=642&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>You may at some stage want to filter an online service based on IP address. In other words, you may want to block or grant access to a request based on their IP address. This can be handled in PHP by doing the following.</p>
<p>If you have the IP addresses, then it is trivial.</p>
<p><pre class="brush: php;">

//First check IP address is valid
$request_ip = $_SERVER['REMOTE_ADDR'];

if ( !preg_match( &quot;/^(([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]).){3}([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$/&quot;, $request_ip ) )
    return false;

$blacklist = array(
'111.222.12.11',
'222.111.21.22',
'221.112.11.12'
);

//check that ip is not blacklisted
if ( in_array( $request_ip, $blacklist ) )
    return false;

</pre></p>
<p>If you want to include a range of IP addresses, best to use a regular expression.</p>
<p><pre class="brush: php;">

$blacklist_ip_range = array(
    '/^122\.244\.(\d+)\.(\d+)/', //for IP address in the range 122.244.0.0 - 122.244.255.255
    '/^123\.(\d+)\.(\d+)\.(\d+)/', //for IP address in the range 123.0.0.0 - 123.255.255.255
);

foreach( $blacklist_ip_range as $ip ) {
    if( preg_match( $ip, $request_ip ) )
       	return false;
    }

</pre></p>
<p>If you have a better solution, then please let me know.</p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/blacklist/'>blacklist</a>, <a href='http://magp.ie/tag/filter/'>filter</a>, <a href='http://magp.ie/tag/ip-address/'>IP address</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/regular-expression/'>regular expression</a>, <a href='http://magp.ie/tag/whitelist/'>whitelist</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/642/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/642/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/642/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=642&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/09/01/filter-ip-addresses-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Debugging PHP by monitoring errors in terminal</title>
		<link>http://magp.ie/2011/03/10/debugging-php-by-monitoring-errors-in-terminal/</link>
		<comments>http://magp.ie/2011/03/10/debugging-php-by-monitoring-errors-in-terminal/#comments</comments>
		<pubDate>Thu, 10 Mar 2011 20:27:00 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Guides]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[command]]></category>
		<category><![CDATA[debugging techniques]]></category>
		<category><![CDATA[debug_backtrace]]></category>
		<category><![CDATA[error_log]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[terminal]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=531</guid>
		<description><![CDATA[This is a super simple command but there is something about the following sequence of characters that I simply cannot retain in my brain. tail -f /tmp/php-errors This is a handy command to debug your PHP on your server where &#8230; <a href="http://magp.ie/2011/03/10/debugging-php-by-monitoring-errors-in-terminal/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=531&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>This is a super simple command but there is something about the following sequence of characters that I simply cannot retain in my brain.<br />
<span id="more-531"></span><br />
<code>tail -f /tmp/php-errors</code></p>
<p>This is a handy command to debug your PHP on your server where you may have errors hidden. </p>
<ul>
<li>The <a href="http://ss64.com/bash/tail.html">tail</a> command shows the end of a file.</li>
<li>The -f flag tells it to keep the file open, while you debug your code</li>
<li>The /tmp/php-error is ( I assume! ) a temporary error log file that stores PHP errors on the server.</li>
<p>.</ul>
<p><strong>Update:</strong></p>
<p>If you use <code>error_log(print_r(debug_backtrace(), true ))</code> with this command, you can monitor the call stack in real time. Super useful when debugging!</p>
<br />Filed under: <a href='http://magp.ie/category/guides/'>Guides</a> Tagged: <a href='http://magp.ie/tag/bash/'>bash</a>, <a href='http://magp.ie/tag/command/'>command</a>, <a href='http://magp.ie/tag/debugging-techniques/'>debugging techniques</a>, <a href='http://magp.ie/tag/debug_backtrace/'>debug_backtrace</a>, <a href='http://magp.ie/tag/error_log/'>error_log</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/terminal/'>terminal</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/531/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/531/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/531/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=531&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/03/10/debugging-php-by-monitoring-errors-in-terminal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Check for Valid XML with PHP</title>
		<link>http://magp.ie/2011/02/12/check-for-valid-xml-with-php/</link>
		<comments>http://magp.ie/2011/02/12/check-for-valid-xml-with-php/#comments</comments>
		<pubDate>Sat, 12 Feb 2011 18:23:11 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[DOMDocument]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[validate]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=513</guid>
		<description><![CDATA[Simple function to check if XML is valid. It just loads the XML into DOMDocument and checks for errors. Filed under: Code Tagged: DOMDocument, php, validate, XML<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=513&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Simple function to check if XML is valid. It just loads the XML into <a href="http://php.net/manual/en/class.domdocument.php">DOMDocument</a> and checks for errors.</p>
<p><pre class="brush: php;">
/**
*  Takes XML string and returns a boolean result where valid XML returns true
*/
function is_valid_xml ( $xml ) {
    libxml_use_internal_errors( true );
    
    $doc = new DOMDocument('1.0', 'utf-8');
    
    $doc-&gt;loadXML( $xml );
    
    $errors = libxml_get_errors();
    
    return empty( $errors );
}
</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/domdocument/'>DOMDocument</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/validate/'>validate</a>, <a href='http://magp.ie/tag/xml/'>XML</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/513/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/513/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/513/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=513&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/02/12/check-for-valid-xml-with-php/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Find duplicates in an array with PHP</title>
		<link>http://magp.ie/2011/02/02/find-duplicates-in-an-array-with-php/</link>
		<comments>http://magp.ie/2011/02/02/find-duplicates-in-an-array-with-php/#comments</comments>
		<pubDate>Wed, 02 Feb 2011 18:07:25 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[duplicates]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=507</guid>
		<description><![CDATA[Here is a function to find duplicate items in an array. Filed under: Code Tagged: array, duplicates, php<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=507&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Here is a function to find duplicate items in an array.</p>
<p><pre class="brush: php;">
/**
* Takes an array and returns an array of duplicate items
*/
function get_duplicates( $array ) {
	return array_unique( array_diff_assoc( $array, array_unique( $array ) ) );
}
</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/array/'>array</a>, <a href='http://magp.ie/tag/duplicates/'>duplicates</a>, <a href='http://magp.ie/tag/php/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/507/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/507/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/507/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=507&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/02/02/find-duplicates-in-an-array-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Regular expression to remove excess whitespace</title>
		<link>http://magp.ie/2011/01/30/regular-expression-to-remove-excess-whitespace/</link>
		<comments>http://magp.ie/2011/01/30/regular-expression-to-remove-excess-whitespace/#comments</comments>
		<pubDate>Sun, 30 Jan 2011 15:11:38 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[strings]]></category>
		<category><![CDATA[tabs]]></category>
		<category><![CDATA[whitespace]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=503</guid>
		<description><![CDATA[Neat way of removing excess whitespace and tabbing from strings. Filed under: Code Tagged: php, regex, strings, tabs, whitespace<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=503&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Neat way of removing excess whitespace and tabbing from strings.</p>
<p><pre class="brush: php;">
$string = &quot;Tom\tThumb\t                is sooooooo\t\t\tdumb&quot;;
$string = preg_replace( '/\s+/', ' ', $string );
echo $string;
//will echo &quot;Tom Thumb is sooooooo dumb&quot;
</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/regex/'>regex</a>, <a href='http://magp.ie/tag/strings/'>strings</a>, <a href='http://magp.ie/tag/tabs/'>tabs</a>, <a href='http://magp.ie/tag/whitespace/'>whitespace</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/503/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/503/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/503/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=503&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/01/30/regular-expression-to-remove-excess-whitespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Convert CSV data into an associative array</title>
		<link>http://magp.ie/2011/01/28/convert-csv-data-into-an-associative-array/</link>
		<comments>http://magp.ie/2011/01/28/convert-csv-data-into-an-associative-array/#comments</comments>
		<pubDate>Fri, 28 Jan 2011 14:41:29 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[parse]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=496</guid>
		<description><![CDATA[If you want to convert comma separated values into an associated array, then use the following code. Note: The code uses the first row of your CSV data to determine the keys in the associative array. Found here, courtesy of &#8230; <a href="http://magp.ie/2011/01/28/convert-csv-data-into-an-associative-array/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=496&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you want to convert comma separated values into an associated array, then use the following code.<br />
<span id="more-496"></span><br />
<strong>Note:</strong> The code uses the first row of your CSV data to determine the keys in the associative array.</p>
<p><pre class="brush: php;">
/**
 * Convert a comma separated file into an associated array.
 * The first row should contain the array keys.
 * 
 * Example:
 * 
 * @param string $filename Path to the CSV file
 * @param string $delimiter The separator used in the file
 * @return array
 * @link http://gist.github.com/385876
 * @author Jay Williams &lt;http://myd3.com/&gt;
 * @copyright Copyright (c) 2010, Jay Williams
 * @license http://www.opensource.org/licenses/mit-license.php MIT License
 */
function csv_to_array($filename='', $delimiter=',')
{
	if(!file_exists($filename) || !is_readable($filename))
		return FALSE;

	$header = NULL;
	$data = array();
	if (($handle = fopen($filename, 'r')) !== FALSE)
	{
		while (($row = fgetcsv($handle, 1000, $delimiter)) !== FALSE)
		{
			if(!$header)
				$header = $row;
			else
				$data[] = array_combine($header, $row);
		}
		fclose($handle);
	}
	return $data;
}
</pre></p>
<p><a href="https://gist.github.com/385876">Found here</a>, courtesy of <a href="https://gist.github.com/jaywilliams">jaywilliams</a></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/array/'>array</a>, <a href='http://magp.ie/tag/csv/'>CSV</a>, <a href='http://magp.ie/tag/format/'>format</a>, <a href='http://magp.ie/tag/github/'>github</a>, <a href='http://magp.ie/tag/parse/'>parse</a>, <a href='http://magp.ie/tag/php/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/496/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/496/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/496/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=496&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/01/28/convert-csv-data-into-an-associative-array/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Tidy and format your PHP and meet WordPress standards on Coda and TextWrangler</title>
		<link>http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/</link>
		<comments>http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/#comments</comments>
		<pubDate>Mon, 10 Jan 2011 21:08:13 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Shortcuts]]></category>
		<category><![CDATA[coda]]></category>
		<category><![CDATA[coding standards]]></category>
		<category><![CDATA[format]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[phptidy]]></category>
		<category><![CDATA[plugin]]></category>
		<category><![CDATA[textwrangler]]></category>
		<category><![CDATA[tidy]]></category>
		<category><![CDATA[wordpress]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=436</guid>
		<description><![CDATA[If you are working in a collaborative environment, coding standards are important. When you are reading through code that you haven&#8217;t written, it helps if it follows a standard. As I work with Automattic, the keepers of WordPress.com, I get &#8230; <a href="http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=436&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you are working in a collaborative environment, coding standards are important. When you are reading through code that you haven&#8217;t written, it helps if it follows a standard.</p>
<p>As I work with <a href="http://automattic.com">Automattic</a>, the keepers of <a href="http://WordPress.com">WordPress.com</a>, I get the opportunity to work on the WordPress Platform. WordPress have their own <a href="http://codex.wordpress.org/WordPress_Coding_Standards">standards</a> that are sensible without being pedantic and are similar to the <a href="http://pear.php.net/manual/en/standards.php">PEAR standard</a>. The emphasis of the standard (in my opinion), is to present your code so collaboration is as easy as possible. It would prefer if you wrote code that is easier to read and understand, even if it is a little longer, than some compressed, <em>ubersmart</em> block of code that only you can follow.<br />
<span id="more-436"></span><br />
Sometimes I look back at old code I did, like when I first wrote a WordPress plugin, and see places where it is not consistent with the WordPress standards&#8230; and I&#8217;d to get the itch to fix it, line by line, which is time consuming and dull work.</p>
<p>So I looked into ways to automate this in my text editor but alas no feature or option existed. While its not really possible to automate for all the standards, it should be possible to correct the formatting.</p>
<p>What can be automated?, well&#8230;</p>
<ul>
<li><strong>Braces style</strong>. It should use <a href="http://en.wikipedia.org/wiki/Indent_style">K&amp;R style</a>.</li>
<li><strong>Indentation</strong>. Need to remove spacing and use tabs instead.</li>
<li><strong>Spacing</strong>. Add spacing to make code more readable.</li>
<li><strong>No shorthand PHP</strong>. So no <code>&lt;?</code> allowed.</li>
</ul>
<p>If you are using <a href="http://www.panic.com/coda/">Coda</a>, there is an excellent plugin called <a href="http://www.chipwreck.de/blog/software/coda-php/">Coda PHP &amp; Web Toolkit</a> written by Mario Fischer. This is easy to install, and all you have to do to tidy your HTML, PHP, Javascript and CSS is right click on your code and select the plugin&#8217;s Tidy option.</p>
<p><a href="http://blogalhost.files.wordpress.com/2011/01/screen-shot-2011-01-07-at-23-20-22.png"><img class="alignnone size-thumbnail wp-image-461" title="Tidy PHP with Coda Plugin" src="http://blogalhost.files.wordpress.com/2011/01/screen-shot-2011-01-07-at-23-20-22.png?w=300&#038;h=38" alt="Tidy PHP with Coda Plugin" width="300" height="38" /></a></p>
<p>The best thing about this, it meets WordPress PHP formatting standards with only a couple of exceptions. To fix them, you need to locate the phptidy-coda.php file, usually found here&#8230;<br />
<code>/Users/[your user name]/Library/Application Support/Coda/Plug-ins/PhpPlugin.codaplugin/Contents/Resources/phptidy-coda.php</code></p>
<p>If you can&#8217;t locate it, go to root and use the following search command.<br />
<code>sudo find . -name "*.php" -exec grep -H "phptidy" {} \;</code></p>
<p>The first exception is, that for functions and classes, it pushes the opening curly bracket, <strong>{</strong>, to the next line.<br />
To fix this, open <strong>phptidy-coda.php</strong> in an editor and change the line</p>
<p><pre class="brush: php;">
// from
$curly_brace_newline = array(T_CLASS, T_FUNCTION);
// to...
$curly_brace_newline = false;
</pre></p>
<p>The other exception is, it does not add spacing after a start round bracket <strong>(</strong>, or before an end round bracket, <strong>)</strong>.</p>
<p>In <strong>phptidy-coda.php</strong>, find the phptidy function and add a default for this formatting with the other defaults&#8230;</p>
<p><pre class="brush: php;">
// Enable the single cleanup functions
$fix_token_case = true;
$fix_builtin_functions_case = true;
$replace_inline_tabs = true;
$replace_phptags = true;
$replace_shell_comments = true;
$fix_statement_brackets = true;
$fix_separation_whitespace = true;
$fix_comma_space = true;

//add new default in here
$fix_round_bracket_space = true;

$add_file_docblock = false;
$add_function_docblocks = false;
$add_doctags = false;
$fix_docblock_format = true;
$fix_docblock_space = false;
$add_blank_lines = false;
$indent = true;
</pre></p>
<p>Then look for the phptidy function and add a check for this default to format the spacing for round brackets.</p>
<p><pre class="brush: php;">
// Simple formatting
if ( $GLOBALS['fix_token_case'] ) fix_token_case( $tokens );
if ( $GLOBALS['fix_builtin_functions_case'] ) fix_builtin_functions_case( $tokens );
if ( $GLOBALS['replace_inline_tabs'] ) replace_inline_tabs( $tokens );
if ( $GLOBALS['replace_phptags'] ) replace_phptags( $tokens );
if ( $GLOBALS['replace_shell_comments'] ) replace_shell_comments( $tokens );
if ( $GLOBALS['fix_statement_brackets'] ) fix_statement_brackets( $tokens );
if ( $GLOBALS['fix_separation_whitespace'] ) fix_separation_whitespace( $tokens );
if ( $GLOBALS['fix_comma_space'] ) fix_comma_space( $tokens );
// Add in you call to new function here
if ( $GLOBALS['fix_round_bracket_space'] ) fix_round_bracket_space( $tokens );
</pre></p>
<p>Lastly, add in the function to format the code to add in spacing after the start round bracket and before the end round bracket where appropriate.</p>
<p><pre class="brush: php;">
/**
 * Adds one space after a start round bracket and before an end round bracket
 *
 * @param array   $tokens (reference)
 */
function fix_round_bracket_space( &amp;$tokens ) {

	foreach ( $tokens as $key =&gt; &amp;$token ) {
		if ( !is_string( $token ) ) continue;
		if (
			// If the current token is a start round bracket...
			$token === &quot;(&quot; and
			// ...and the next token is no whitespace
			!( isset( $tokens[$key+1][0] ) and $tokens[$key+1][0] === T_WHITESPACE ) and
			// ...and the next token is not an end round bracket
			!( isset( $tokens[$key+1][0] ) and $tokens[$key+1][0] === ')' )
		) {
			// Insert one space
			array_splice( $tokens, $key+1, 0, array(
					array( T_WHITESPACE, &quot; &quot; )
				) );
		}
		else if (
			// If the current token is an end round bracket...
			$token === &quot;)&quot; and
			// ...and the previous token is no whitespace
			!( isset( $tokens[$key-1][0] ) and $tokens[$key-1][0] === T_WHITESPACE ) and
			// ...and the previous token is a start round bracket
			!( isset( $tokens[$key-1][0] ) and $tokens[$key-1][0] === '(' )
		) {
			// Insert one space
			array_splice( $tokens, $key, 0, array(
					array( T_WHITESPACE, &quot; &quot; )
				) );
		}
	}
}
</pre></p>
<p>Then save the file. You may need to edit this file using sudo in order to change it.<br />
Restart Coda and tidy your PHP.</p>
<p><em><strong>UPDATE</strong>:: Mario has told me that he will include these changes in a future update But in case it is not in the next update, you should make a backup of the phptidy-coda.php file, as the next plugin update may overwrite it.</em></p>
<p><em><strong>UPDATE 2</strong>:: Mario has indeed included these changes into the lastest version of the plugin. He has also made the format configurable so if you don&#8217;t want your curly brackets on the same line, you can set it so.</em></p>
<p>Now that is all good and well if you have Coda, but what of the <a href="http://www.barebones.com/products/textwrangler/">TextWrangler</a> folk. Well the plugin for Coda uses an open sourced library called <a href="http://phptidy.berlios.de/">phptidy</a>, written by Magnus Rosenbaum, which is impressive not least for the brevity of the documentation.</p>
<p>To get it to work with TextWrangler is fairly straightforward. Follow these steps and if I have left any out place highlight them in the comments below.</p>
<p><strong>Note:</strong> I had to make some minor changes to the phptidy library to get it to work with TextWrangler. As well as the 2 changes above, I also had to suppress any text echo&#8217;d by the library.</p>
<ul>
<li>Download my <a href="http://dl.dropbox.com/u/5756988/phptidy.zip">phptidy</a> library.</li>
<li>Uncompress the zip file and copy the <strong>Tidy PHP.sh</strong> file to the Filters directory, you can find out how to do that <a href="http://magp.ie/2010/02/15/format-xml-with-textwrangler/">here</a></li>
<li>Open terminal and copy the <strong>phptidy.php</strong> file to your <code>/usr/bin</code> folder</li>
<li>Go to the <code>/usr/bin</code> folder and change the file permissions of the <strong>phptidy.php</strong> by typing, <code>sudo chmod 755 phptidy.php</code></li>
</ul>
<p>Now you should be ready to try out the filter in TextWrangler.</p>
<p>At a later date, I plan to use John Godley&#8217;s <a href="http://urbangiraffe.com/articles/wordpress-codesniffer-standard/">CodeSniffer code</a>, to validate the code and get a detailed explanation of where the code does not follow the WordPress standard.</p>
<br />Filed under: <a href='http://magp.ie/category/shortcuts/'>Shortcuts</a> Tagged: <a href='http://magp.ie/tag/coda/'>coda</a>, <a href='http://magp.ie/tag/coding-standards/'>coding standards</a>, <a href='http://magp.ie/tag/format/'>format</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/phptidy/'>phptidy</a>, <a href='http://magp.ie/tag/plugin/'>plugin</a>, <a href='http://magp.ie/tag/textwrangler/'>textwrangler</a>, <a href='http://magp.ie/tag/tidy/'>tidy</a>, <a href='http://magp.ie/tag/wordpress/'>wordpress</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/436/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/436/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/436/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=436&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/01/10/tidy-and-format-your-php-and-meet-wordpress-standards-on-coda-and-textwrangler/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>

		<media:content url="http://blogalhost.files.wordpress.com/2011/01/screen-shot-2011-01-07-at-23-20-22.png?w=300" medium="image">
			<media:title type="html">Tidy PHP with Coda Plugin</media:title>
		</media:content>
	</item>
		<item>
		<title>Remove non-UTF8 characters from string with PHP</title>
		<link>http://magp.ie/2011/01/06/remove-non-utf8-characters-from-string-with-php/</link>
		<comments>http://magp.ie/2011/01/06/remove-non-utf8-characters-from-string-with-php/#comments</comments>
		<pubDate>Thu, 06 Jan 2011 21:58:22 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[regex]]></category>
		<category><![CDATA[UTF8]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=447</guid>
		<description><![CDATA[If you have come across the cursed &#8216;Invalid Character&#8216; error while using PHP&#8217;s XML or JSON parser then you may be interested in this. Unfortunately, PHP&#8217;s XML and JSON parsers do not ignore non-UTF8 characters, but rather they stop and &#8230; <a href="http://magp.ie/2011/01/06/remove-non-utf8-characters-from-string-with-php/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=447&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>If you have come across the cursed &#8216;<a href="http://petewarden.typepad.com/searchbrowser/2008/04/illegal-charact.html">Invalid Character</a>&#8216; error while using PHP&#8217;s <a href="http://ie2.php.net/manual/en/book.xml.php">XML</a> or <a href="http://www.php.net/manual/en/book.json.php">JSON</a> parser then you may be interested in this.<br />
<span id="more-447"></span><br />
Unfortunately, PHP&#8217;s XML and JSON parsers do not ignore non-UTF8 characters, but rather they stop and throw a rather unhelpful error. I found a number of solutions to this that did not work for me, namely using <a href="http://www.php.net/manual/en/function.iconv.php">iconv</a> and <a href="http://www.php.net/manual/en/function.utf8-encode.php">utf8_encode</a>.</p>
<p>Then I found this <a href="http://webcollab.sourceforge.net/unicode.html">excellent explanation</a> of using UTF8 with PHP, which is well worth a read.</p>
<p>Encoding gives me a headache but from this explanation this is how I see it. </p>
<p>I had some character that the parser does not know how to interput because it was outside the byte range of the <a href="http://en.wikipedia.org/wiki/UTF-8">UTF8</a> format. Some of the PHP functions, like iconv, still let some non-UTF8 characters through which breaks the parser. The <a href="http://www.php.net/manual/en/function.preg-replace.php">preg_replace</a> just rips out any non-UTF8 character based on it&#8217;s byte sequence and replaces it with a question mark. </p>
<p>From that article above, I use the following code to remove any non-UTF8 characters.</p>
<p><pre class="brush: php;">
//reject overly long 2 byte sequences, as well as characters above U+10000 and replace with ?
$some_string = preg_replace('/[\x00-\x08\x10\x0B\x0C\x0E-\x19\x7F]'.
 '|[\x00-\x7F][\x80-\xBF]+'.
 '|([\xC0\xC1]|[\xF0-\xFF])[\x80-\xBF]*'.
 '|[\xC2-\xDF]((?![\x80-\xBF])|[\x80-\xBF]{2,})'.
 '|[\xE0-\xEF](([\x80-\xBF](?![\x80-\xBF]))|(?![\x80-\xBF]{2})|[\x80-\xBF]{3,})/S',
 '?', $some_string );

//reject overly long 3 byte sequences and UTF-16 surrogates and replace with ?
$some_string = preg_replace('/\xE0[\x80-\x9F][\x80-\xBF]'.
 '|\xED[\xA0-\xBF][\x80-\xBF]/S','?', $some_string );
</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/encoding/'>encoding</a>, <a href='http://magp.ie/tag/php/'>php</a>, <a href='http://magp.ie/tag/regex/'>regex</a>, <a href='http://magp.ie/tag/utf8/'>UTF8</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/447/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/447/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/447/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=447&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2011/01/06/remove-non-utf8-characters-from-string-with-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
		<item>
		<title>Export data to Google spreadsheet with OAuth</title>
		<link>http://magp.ie/2010/11/17/export-data-google-spreadsheet-api-oauth/</link>
		<comments>http://magp.ie/2010/11/17/export-data-google-spreadsheet-api-oauth/#comments</comments>
		<pubDate>Wed, 17 Nov 2010 23:48:51 +0000</pubDate>
		<dc:creator>Eoin</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[CSV]]></category>
		<category><![CDATA[Google API]]></category>
		<category><![CDATA[OAuth]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://magp.ie/?p=375</guid>
		<description><![CDATA[I was working on exporting CSV data to a Google spreadsheet recently. The first thing I had to do was implement a way to allow a user to authenticate themselves with Google from our site. There are a few ways &#8230; <a href="http://magp.ie/2010/11/17/export-data-google-spreadsheet-api-oauth/">Continue reading <span class="meta-nav">&#8594;</span></a><img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=375&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I was working on exporting CSV data to a Google spreadsheet recently. The first thing I had to do was implement a way to allow a user to authenticate themselves with Google from our site. There are a few ways of doing this.</p>
<p>I choose <a href="http://code.google.com/apis/accounts/docs/OAuth.html">OAuth</a> as I thought it would be simplest. I found it was pretty straightforward but there were gaps in Google&#8217;s <a href="http://code.google.com/apis/accounts/docs/OAuth_ref.html">documentation</a> that made the process a tad frustrating.</p>
<p>Here&#8217;s a brief outline&#8230;<br />
<span id="more-375"></span></p>
<p>Couple of things you&#8217;ll need before you can start any coding.</p>
<p><a href="http://code.google.com/apis/accounts/docs/RegistrationForWebAppsAuto.html">Register with Google</a> &#8211; You&#8217;ll need to register with Google to get an API or a consumer key/secret that will be needed to access API.</p>
<p>Get the <a href="http://oauth.googlecode.com/svn/code/php/OAuth.php">OAuth Library</a> &#8211; You will be essentially making signed HTTP requests to Google URLs and this library helps to make sure these requests are constructed properly. I used <a href="http://term.ie">Andy Smith&#8217;s</a> <a href="http://oauth.googlecode.com/svn/code/php/OAuth.php">PHP library</a>.</p>
<p>I have a Google PHP class that handles the authorization and uploading data to a Google Spreadsheet. </p>
<p>One critical step in authenticating that I couldn&#8217;t find in the Google documentation is the following step. When you get the request token, a token secret is sent in the response. You need to save the request token secret so you can use this token secret again when you request the access token. I am saving it as meta data but you can easily use a session variable.</p>
<p>Uploading data to Google also has a few hoops. You can only upload a max of 1MB so you may need to break up the upload into multiple documents. They recommend using <a href="http://code.google.com/apis/documents/docs/3.0/developers_guide_protocol.html#ResumableUpload">Resumable Upload</a> when uploading bigger lumps of data. This requires you to chuck the data and use the Content-Range to specify the chuck sizes. </p>
<p><pre class="brush: php;">
define( 'CONSUMER_KEY', 'domain.com' );
define( 'CONSUMER_SECRET', '324lewrl34j234kp234' );

class Google_Doc {
	private $user;

	public function __construct( $user = false ) {
		global $current_user;

		$this-&gt;user = $user;
		if ( $user === false )
			$this-&gt;user = $current_user;
	}

	private function get_token() {
		return $this-&gt;user-&gt;get_meta( 'google_oauth_token' );
	}

	public function is_authorised() {
		$access_token = $this-&gt;get_token();

		if ( $access_token instanceof OAuthToken )
			return true;
		return false;
	}

	public function authorise() {
		$authorize_url = '';
		$parameters    = array();

		if ( isset( $_REQUEST['oauth_verifier'] ) ) {
			// This is the callback from Google after verifying
			$oauth_verifier = $_REQUEST['oauth_verifier'];

			$parameters[ 'oauth_verifier' ] = $oauth_verifier;
			if ( isset( $_REQUEST['oauth_token'] ) ) {
				$parameters[ 'oauth_token' ] = $_REQUEST['oauth_token'];

				$access_token = $this-&gt;get_access_token( $parameters );

				// Delete the meta secret token
				delete_metadata( 'user', $this-&gt;user-&gt;get_id(), 'google_token_secret' );

				if ( $access_token ) {
					// Store the token
					$this-&gt;user-&gt;set_meta( 'google_oauth_token', $access_token );
					return true;
				}
			}
		}
		else {
			// Unauthorised - send user to Google
			$parameters = array(
				'scope'          =&gt; 'http://docs.google.com/feeds/',
				'oauth_callback' =&gt; &quot;http://{$_SERVER['HTTP_HOST']}{$_SERVER['REQUEST_URI']}&quot;
			);

			$request_token = $this-&gt;get_request_token( $parameters );
			if ( $request_token ) {
				$authorize_url = 'https://www.google.com/accounts/OAuthAuthorizeToken?'.$request_token;
				pd_redirect( $authorize_url );
			}
		}

		return false;
	}

	public static function max_upload_size() {
		return 1024 * 1024;
	}

	private function get_request_token( $parameters ) {
		$consumer     = new OAuthConsumer( CONSUMER_KEY, CONSUMER_SECRET );
		$sig_method   = new OAuthSignatureMethod_HMAC_SHA1();
		$token = $key = $secret = NULL;

		$token_endpoint = 'https://www.google.com/accounts/OAuthGetRequestToken';

		$request = OAuthRequest::from_consumer_and_token( $consumer, $token, 'GET', $token_endpoint, $parameters );
		$request-&gt;sign_request( $sig_method, $consumer, $token);

		$response = send_signed_request( $request-&gt;get_normalized_http_method(), $token_endpoint, $request-&gt;to_header(), NULL, false );

		// Parse out oauth_token (access token) and oauth_token_secret
		if ( preg_match( '/oauth_token=(.*)&amp;oauth_token_secret=(.*)&amp;/', $response, $matches ) &gt; 0 ) {
			$key    = urldecode( $matches[1] );
			$secret = urldecode( $matches[2] );

			$this-&gt;user-&gt;set_meta( 'google_token_secret', $secret );
			$token = new OAuthToken( $key, $secret );
		}

		return $token;
	}

	private function get_access_token( $parameters ) {
		$consumer   = new OAuthConsumer( CONSUMER_KEY, CONSUMER_SECRET );
		$sig_method = new OAuthSignatureMethod_HMAC_SHA1();
		$token      = new OAuthToken( $parameters['oauth_token'], $this-&gt;user-&gt;get_meta( 'google_token_secret' ) );

		$token_endpoint = 'https://www.google.com/accounts/OAuthGetAccessToken';

		$request = OAuthRequest::from_consumer_and_token( $consumer, $token, 'GET', $token_endpoint, $parameters );
		$request-&gt;sign_request( $sig_method, $consumer, $token );

		$response = send_signed_request( $request-&gt;get_normalized_http_method(), $token_endpoint, $request-&gt;to_header(), NULL, false );

		// Parse out oauth_token (access token) and oauth_token_secret
		$token = false;
		if ( preg_match('/oauth_token=(.*)&amp;oauth_token_secret=(.*)/', $response, $matches) &gt; 0 )
			$token = new OAuthToken( urldecode( $matches[1] ), urldecode( $matches[2] ) );

		return $token;
	}

	public function upload( $data, $slug ) {
		// Squirt it over to Google
		$consumer       = new OAuthConsumer( CONSUMER_KEY, CONSUMER_SECRET );
		$sig_method     = new OAuthSignatureMethod_HMAC_SHA1();
		$token_endpoint = 'http://docs.google.com/feeds/upload/create-session/default/private/full';

		$access_token = $this-&gt;get_token();

		$filesize = strlen( $data );

		$request = OAuthRequest::from_consumer_and_token( $consumer, $access_token, 'POST', $token_endpoint, NULL );
		$request-&gt;sign_request( $sig_method, $consumer, $access_token );

		$headers = array(
			'Content-Type: text/csv',
			'Content-Length: 0',
			&quot;Slug: &quot;.$slug,
			'GData-Version: 3.0',
			'X-Upload-Content-Type: text/csv',
			&quot;X-Upload-Content-Length: {$filesize}&quot;,
			$request-&gt;to_header()
		);

		$response = send_signed_request( $request-&gt;get_normalized_http_method(), $token_endpoint, $headers, NULL, true );

		if ( preg_match( '/Location:(.*)/', $response, $matches ) &gt; 0 ) {
			$url = trim( $matches[1] );

			$chunk_size = 256 * 1024;
			$start      = 0;

			while ( $start &lt; $filesize ) {
				$chunk = substr( $data, $start, min( $filesize - $start, $chunk_size ) );

				$headers = array(
					'Content-Type: text/csv',
					&quot;Content-Length: &quot;.strlen( $chunk ),
					sprintf( &quot;Content-Range: bytes %d-%d/%d&quot;, $start, strlen( $chunk ) - 1, $filesize )
				);

				$curl = curl_init( $url );

				curl_setopt( $curl, CURLOPT_RETURNTRANSFER, true );
				curl_setopt( $curl, CURLOPT_FAILONERROR, true );
				curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, false );
				curl_setopt( $curl, CURLOPT_HTTPHEADER, $headers );
				curl_setopt( $curl, CURLOPT_CUSTOMREQUEST, 'PUT' );
				curl_setopt( $curl, CURLOPT_POSTFIELDS, $chunk );
				curl_setopt( $curl, CURLOPT_TIMEOUT, 10 );

				$response = curl_exec( $curl );
				$http_status = curl_getinfo( $curl, CURLINFO_HTTP_CODE );

				curl_close( $curl );

				if ( $response !== false ) {
					// Is this the last chunk?
					if ( $http_status == 201 ) {
						// Parse out the doc URL
						$xml = simplexml_load_string( $response );
						if ( $xml ) {
							foreach ( $xml-&gt;link AS $link ) {
								if ( $link['rel'] == 'alternate' )
									return (string)$link['href'];
							}
						}

						return false;
					}

					$start += strlen( $chunk );
				}
				else
					return $this-&gt;failed();
			}
		}

		return $this-&gt;failed();
	}

	/**
	 * Operation failed so delete the auth token
	 */
	private function failed() {
		delete_metadata( 'user', $this-&gt;user-&gt;get_id(), 'google_oauth_token' );
		return false;
	}
}
/**
 * Makes an HTTP request to the specified URL
 *
 * @param string  $http_method           The HTTP method (GET, POST, PUT, DELETE)
 * @param string  $url                   Full URL of the resource to access
 * @param string  $auth_header           (optional) Authorization header
 * @param string  $postData              (optional) POST/PUT request body
 * @param bool    $returnResponseHeaders True if resp. headers should be returned.
 * @return string Response body from the server
 */
function send_signed_request($http_method, $url, $auth_header=null, $postData=null, $returnResponseHeaders=true)
{
	$curl = curl_init($url);
	curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
	curl_setopt($curl, CURLOPT_FAILONERROR, false);
	curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

	if ($returnResponseHeaders) {
		curl_setopt($curl, CURLOPT_HEADER, true);
		curl_setopt($curl, CURLINFO_HEADER_OUT, true);
	}

	if ($auth_header) {
		if ( is_string( $auth_header ) )
			$auth_header = array( $auth_header );
		curl_setopt($curl, CURLOPT_HTTPHEADER, $auth_header);
	}

	if ($http_method == 'POST') {
		curl_setopt($curl, CURLOPT_POST, 1);
		curl_setopt($curl, CURLOPT_POSTFIELDS, $postData);
	}
	$response = curl_exec($curl);
	if (!$response) {
		$response = curl_error($curl);
	}
	curl_close($curl);
	return $response;
}
</pre></p>
<p>To use this class, just place the following code in a page.</p>
<p><pre class="brush: php;">
$google = new Google_Doc();

if ( $google-&gt;is_authorised() ) {
	$google-&gt;upload( $data, $slug );
}
else {
	if ( $google-&gt;authorise() ) {
		$google-&gt;upload( $data, $slug );
	}
}
</pre></p>
<br />Filed under: <a href='http://magp.ie/category/code/'>Code</a> Tagged: <a href='http://magp.ie/tag/csv/'>CSV</a>, <a href='http://magp.ie/tag/google-api/'>Google API</a>, <a href='http://magp.ie/tag/oauth/'>OAuth</a>, <a href='http://magp.ie/tag/php/'>php</a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/blogalhost.wordpress.com/375/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/blogalhost.wordpress.com/375/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/blogalhost.wordpress.com/375/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=magp.ie&amp;blog=11708208&amp;post=375&amp;subd=blogalhost&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://magp.ie/2010/11/17/export-data-google-spreadsheet-api-oauth/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<georss:point>53.734750 -8.989992</georss:point>
		<geo:lat>53.734750</geo:lat>
		<geo:long>-8.989992</geo:long>
		<media:content url="http://1.gravatar.com/avatar/72dd449e5e79e046c1c09ed8712b525a?s=96&#38;d=monsterid&#38;r=PG" medium="image">
			<media:title type="html">eoigal</media:title>
		</media:content>
	</item>
	</channel>
</rss>
