  <?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>Chob &#187; PHP</title>
	<atom:link href="http://blog.chop.com.au/category/dev/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.chop.com.au</link>
	<description>Blog of Leon Wilson, a freelance flash developer based in Sydney, Australia.</description>
	<lastBuildDate>Sat, 21 Jan 2012 22:43:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Loop through XML elements using PHP</title>
		<link>http://blog.chop.com.au/2012/01/loop-through-xml-nodes-using-php/</link>
		<comments>http://blog.chop.com.au/2012/01/loop-through-xml-nodes-using-php/#comments</comments>
		<pubDate>Sat, 21 Jan 2012 22:33:57 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[foreach]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=1323</guid>
		<description><![CDATA[If you don&#8217;t know the absolute path of an element in your xml file the using xpath and &#8216;//&#8217; acts as a wildcard (similar to &#8216;..&#8217; in as3 i guess) you can run a loop and return all values for those elements. Handy for this likes RSS feeds or KML files ect.]]></description>
			<content:encoded><![CDATA[<p>If you don&#8217;t know the absolute path of an element in your xml file the using xpath and &#8216;//&#8217; acts as a wildcard (similar to &#8216;..&#8217; in as3 i guess) you can run a loop and return all values for those elements.</p>
<p>Handy for this likes RSS feeds or KML files ect.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

$xml = simplexml_load_file('my.xml');

	foreach ($xml-&gt;xpath('//xmlnode')  as $node) {
    	echo &quot;\t node: $node &lt;br /&gt;\n&quot;;

	}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2012/01/loop-through-xml-nodes-using-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Handy Hint: AMFPHP to Flash Character Encoding</title>
		<link>http://blog.chop.com.au/2010/06/handy-hint-amfphp-to-flash-character-encoding/</link>
		<comments>http://blog.chop.com.au/2010/06/handy-hint-amfphp-to-flash-character-encoding/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 03:11:41 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[amfphp]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[hint]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=180</guid>
		<description><![CDATA[If you&#8217;ve ever used AMFPHP to connect your DB into Flash, you may stumble across weird characters being output! eg: â€“ replaces the ’. The simple explanation is that the PHP is decoding it wrong. Forget about preg_replace(), all you need to do is update your amfphp/gateway.php file to decode, encode in UTF-8. and walla [...]]]></description>
			<content:encoded><![CDATA[<p>If you&#8217;ve ever used AMFPHP to connect your DB into Flash, you may stumble across weird characters being output! eg: â€“ replaces the ’. The simple explanation is that the PHP is decoding it wrong.</p>
<p>Forget about preg_replace(), all you need to do is update your amfphp/gateway.php file to decode, encode in UTF-8.</p>
<pre class="brush: php; title: ; notranslate">

$gateway-&gt;setCharsetHandler(&quot;utf8_decode&quot;, &quot;UTF-8&quot;, &quot;UTF-8&quot;);
</pre>
<p>and walla no more annoying characters sent from AMFPHP.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2010/06/handy-hint-amfphp-to-flash-character-encoding/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP &#8211; having problems with getimagesize() when space in filename?</title>
		<link>http://blog.chop.com.au/2010/04/php-having-problems-with-getimagesize-when-space-in-filename/</link>
		<comments>http://blog.chop.com.au/2010/04/php-having-problems-with-getimagesize-when-space-in-filename/#comments</comments>
		<pubDate>Thu, 29 Apr 2010 08:09:22 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=157</guid>
		<description><![CDATA[Some images containing spces in the file name led me to some errors when trying to determine their image size for manipulation using PHP. Simply url encoding the string fixed this problem.  ]]></description>
			<content:encoded><![CDATA[<p>Some images containing spces in the file name led me to some errors when trying to determine their image size for manipulation using PHP.</p>
<p>Simply url encoding the string fixed this problem.<br />
 </p>
<pre class="brush: php; title: ; notranslate"> &lt;?php
  $imagePath = &quot;some funky filename.jpg&quot;;
  $imagePath = str_replace(&quot; &quot;,&quot;%20&quot;,$imagePath);
  list($imgwidth,$imgheight) = getimagesize($imagePath);
?&gt;
</pre>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2010/04/php-having-problems-with-getimagesize-when-space-in-filename/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Snippet &#8211; GetFileContents and save PDF</title>
		<link>http://blog.chop.com.au/2010/04/php-snippet-getfilecontents-save-output/</link>
		<comments>http://blog.chop.com.au/2010/04/php-snippet-getfilecontents-save-output/#comments</comments>
		<pubDate>Sat, 03 Apr 2010 03:51:28 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=152</guid>
		<description><![CDATA[I needed to be able to access a pdf outside my document root&#8230; so I created the script below. Using just file_get_contents with an echo would just save it as the name of the script, using an $output_file variable and in the header you are able to specify what you want to save it as.]]></description>
			<content:encoded><![CDATA[<p>I needed to be able to access a pdf outside my document root&#8230; so I created the script below. Using just file_get_contents with an echo would just save it as the name of the script, using an $output_file variable and in the header you are able to specify what you want to save it as.</p>
<pre class="brush: php; title: ; notranslate">

&lt;?php
$output_file = 'outfilename.pdf';
$file = &quot;target.pdf&quot;;
$fileDir = '../target/directory/';
$contents = file_get_contents($fileDir.$file);
header(&quot;Content-Disposition: attachment; filename=&quot; . $output_file);
header('Content-type: application/pdf');
echo $contents;
exit();
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2010/04/php-snippet-getfilecontents-save-output/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Snippet &#8211; Get Yesterdays date</title>
		<link>http://blog.chop.com.au/2010/02/php-snippet-get-yesterdays-date/</link>
		<comments>http://blog.chop.com.au/2010/02/php-snippet-get-yesterdays-date/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 03:43:05 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=139</guid>
		<description><![CDATA[This is a simple function that returns yesterdays date. Simple but handy.]]></description>
			<content:encoded><![CDATA[<p>This is a simple function that returns yesterdays date. Simple but handy.</p>
<pre class="brush: php; title: ; notranslate">function yesterday()
{
 $yesterday = date(&quot;Y:m:d&quot;,mktime(0,0,0,date(&quot;m&quot;) ,date(&quot;d&quot;)-1,date(&quot;Y&quot;)));
 return $yesterday;
}</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2010/02/php-snippet-get-yesterdays-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Snippet &#8211; Time difference between 2 date/time stamps.</title>
		<link>http://blog.chop.com.au/2010/02/php-get-yesterdays-date/</link>
		<comments>http://blog.chop.com.au/2010/02/php-get-yesterdays-date/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 03:03:25 +0000</pubDate>
		<dc:creator>chop</dc:creator>
				<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Dev]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://blog.chop.com.au/?p=131</guid>
		<description><![CDATA[In a recent project I needed to capture how long the user spent on the application, it was not expected they would spend days on it so it return hours minutes seconds which can be saved to a database. So basically here is a function to do that&#8230;]]></description>
			<content:encoded><![CDATA[<p>In a recent project I needed to capture how long the user spent on the application, it was not expected they would spend days on it so it return hours minutes seconds which can be saved to a database.<br />
So basically here is a function to do that&#8230;</p>
<pre class="brush: php; title: ; notranslate">
//
echo getTimeDifference(&quot;2010-02-26 18:35:36&quot;);

function getTimeDifference($start_time){

 //convert $start_time into a usable string
 $tempStart = preg_replace('/(\d{2})-(\d{2})-(\d{2})(.*)/', '$1:$2:$3:$4',$start_time);
 $tempStart=explode(&quot;:&quot;,$tempStart);

 $year = $tempStart[0];
 $month= $tempStart[1];
 $day = $tempStart[2];
 $hour = $tempStart[3];
 $minute = $tempStart[4];
 $second = $tempStart[5];

 //set the end time as current time
 $timesEnd = date(&quot;Y:m:d:H:i:s&quot;);
 $tempEnd=explode(&quot;:&quot;,$timesEnd);

 $year1 = $tempEnd[0];
 $month1= $tempEnd[1];
 $day1 = $tempEnd[2];
 $hour1 = $tempEnd[3];
 $minute1 = $tempEnd[4];
 $second1 = $tempEnd[5];

 $countdown_date = mktime($hour, $minute, $second, $month, $day, $year);
 $countdown_date1 = mktime($hour1, $minute1, $second1, $month1, $day1, $year1);

 $diff = $countdown_date1 -$countdown_date ;
 if ($diff &lt; 0)
 $diff = 0;
 $dl = floor($diff/60/60/24);
 $hl = floor(($diff - $dl*60*60*24)/60/60);
 $ml = floor(($diff - $dl*60*60*24 - $hl*60*60)/60);
 $sl = floor(($diff - $dl*60*60*24 - $hl*60*60 - $ml*60)
 );

 $timeDifference = &quot;$hl:$ml:$sl&quot;;

 return $timeDifference;
 }
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.chop.com.au/2010/02/php-get-yesterdays-date/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

