<?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>boolean.co.nz &#187; PHP</title>
	<atom:link href="http://boolean.co.nz/blog/category/development/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://boolean.co.nz/blog</link>
	<description>Where there is more to logic than TRUE or FALSE</description>
	<lastBuildDate>Fri, 18 May 2012 09:56:24 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Speeding up PHP FOR loops</title>
		<link>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/</link>
		<comments>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/#comments</comments>
		<pubDate>Wed, 11 Apr 2012 06:36:40 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=762</guid>
		<description><![CDATA[Refactoring some client code the other day I found a lot of inefficient logic. Whilst this example is written in PHP the concept is applicable in other programming languages. Many people use for loops in the belief that they are faster than a foreach, and while this is often the case it can be slower [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Refactoring some client code the other day I found a lot of inefficient logic. Whilst this example is written in PHP the concept is applicable in other programming languages.</p>
<p>Many people use for loops in the belief that they are faster than a foreach, and while this is often the case it can be slower and less flexible if you make some simple mistakes. Consider the following:</p>
<p><strong>A slow FOR loop</strong></p>
<div class="codesnip-container" >$text=&#8221;thequickbrownfoxjumpsoverthelazydog&#8221;;<br />
for($i=0; $i &lt; strlen($text); $i++){ // Loop through the characters<br />
echo ( substr($text,$i,1) == &#8216;o&#8217; ) ? &#8220;Its an o&#8221; : &#8220;Not an o&#8221;; // Display true or false as relevant<br />
}</div>
<p><strong>A faster FOR loop</strong></p>
<div class="codesnip-container" >$text=&#8221;thequickbrownfoxjumpsoverthelazydog&#8221;;<br />
$length = strlen($text); // obtain length of the string<br />
for($i=0; $i &lt; $length ; $i++){ // Loop through the characters<br />
    echo ( substr($text,$i,1) == &#8216;o&#8217; ) ? &#8220;Its an o&#8221; : &#8220;Not an o&#8221;; // Display true or false as relevant<br />
}</div>
<p>The second loop is faster because it does not evaluate the string length each time the loop runs <em>strlen($text)</em> as in the first example. Small differences like this can have a large effect on the speed of scripts especially if there are many loops or iterations.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/speeding-up-php-for-loops/762/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>08/02/2012 Emergency PHP Updates on server</title>
		<link>http://boolean.co.nz/blog/emergency-php-updates/725/</link>
		<comments>http://boolean.co.nz/blog/emergency-php-updates/725/#comments</comments>
		<pubDate>Tue, 07 Feb 2012 21:42:11 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=725</guid>
		<description><![CDATA[EMERGENCY PHP UPDATES We will be applying a PHP update to the servers later this evening. This will take the primary PHP install from v5.3.9 to v5.3.10 and will resolve a vulnerability that has been patched in the 5.3.10 release. The vulnerability present in 5.3.9 allows for the possibility of remote code execution depending on [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p><strong>EMERGENCY PHP UPDATES</strong></p>
<p>We will be applying a PHP update to the servers later this evening.</p>
<p>This will take the primary PHP install from v5.3.9 to v5.3.10 and will resolve a vulnerability that has been patched in the 5.3.10 release.</p>
<p>The vulnerability present in 5.3.9 allows for the possibility of remote code execution depending on how large numbers and arrays are used.</p>
<p>As this is a security issue we will be performing emergency maintenance between <strong>midnight and 3am (GMT).</strong></p>
<p>There should be no interruption to service however, as the work is being done on components critical to PHP based sites, this period should be considered at risk.</p>
<p>The work will cause slightly higher than normal load on the servers and may involve a restart of the web server.</p>
<p>In the worst cast scenario (such as a failed compile) the installer will restore a backup of the current working configuration.</p>
<p>No module or configuration changes will be made to the PHP stack and scripts should notice no difference.</p>
<p>You can view the change log on the php.net site: <a href="http://php.net/ChangeLog-5.php" title="here" target="_blank">http://php.net/ChangeLog-5.php</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/emergency-php-updates/725/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtain Facebook likes via PHP SDK</title>
		<link>http://boolean.co.nz/blog/facebook-likes-sdk/713/</link>
		<comments>http://boolean.co.nz/blog/facebook-likes-sdk/713/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 03:11:36 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[FaceBook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=713</guid>
		<description><![CDATA[In an update to this post here is another way to obtain the number of likes for a Facebook page. I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code. require(&#8216;facebook.php&#8217;); Setup an array with your Facebook applications credentials $facebook = new Facebook(array( [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>In an update to this <a href="http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/" title="post" target="_blank">post</a> here is another way to obtain the number of likes for a Facebook page.</p>
<p>I&#8217;ll assume that you&#8217;ve already registered a Facebook application, have downloaded the PHP SDK and have included for use in your code.</p>
<div class="codesnip-container" >require(&#8216;facebook.php&#8217;);</div>
<p>Setup an array with your Facebook applications credentials</p>
<div class="codesnip-container" >$facebook = new Facebook(array(<br />
&#8216;appId&#8217; => &#8217;000000000&#8242;, // Put appID here<br />
&#8216;secret&#8217; => &#8217;0000c000c000c000c&#8217;, // Put your secret key here<br />
));</div>
<p>Decide which page you wish to obtain the number of likes for</p>
<div class="codesnip-container" >$getRequest = $facebook->api(&#8216;/cocacola&#8217;); // Lets look at the Facebook page for the popular soft drink<br />
echo $getRequests['likes'];</div>
<p>Obviously you can consume, contrast and display this information in more exciting ways than simply echoing it to the screen. Enjoy.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/facebook-likes-sdk/713/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use PHP to display Gravatar images</title>
		<link>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/</link>
		<comments>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/#comments</comments>
		<pubDate>Fri, 14 Oct 2011 03:34:25 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=668</guid>
		<description><![CDATA[All URLs on Gravatar are based on the use of the hashed value of an email address. According to their best practice you should: Trim leading and trailing whitespace from an email address Force all characters to lower-case md5 hash the final string Of course in PHP this is trivial as the following function shows: [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>All URLs on <a href="http://en.gravatar.com/site/implement/hash/" target="_blank">Gravatar</a> are based on the use of the hashed value of an email address. According to their best practice you should:</p>
<ol>
<li>Trim leading and trailing whitespace from an email address</li>
<li>Force all characters to lower-case</li>
<li>md5 hash the final string</li>
</ol>
<p>Of course in PHP this is trivial as the following function shows:</p>
<div class="codesnip-container" >function fetchGravatar() {<br />
$fetchHash = md5(strtolower(trim(&#8216;your_email.address.com&#8217;)));<br />
$GravatarImage = &#8216;http://www.gravatar.com/avatar/&#8217; . $fetchHash;<br />
return $GravatarImage;<br />
}</div>
<p><a href="http://en.gravatar.com/site/implement/profiles/" target="_blank">Profiles</a> are also available if you require them.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/use-php-to-display-gravatar-images/668/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Host Settings Without phpinfo()</title>
		<link>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/</link>
		<comments>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/#comments</comments>
		<pubDate>Wed, 05 Oct 2011 09:36:05 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[Hosting]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=652</guid>
		<description><![CDATA[Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes. &#60;?php $d_func = ini_get(&#8220;disable_functions&#8221;); $up_max = ini_get(&#8220;upload_max_filesize&#8221;); $up_max = str_replace(&#8220;M&#8221;,&#8221;",$up_max); $up_max_size = &#8220;Megabytes&#8221;; $post_max = ini_get(&#8220;post_max_size&#8221;); $post_max = [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" />
<td>
<tr></table>
<p>Occasionally a webhost will block the very useful phpinfo() command making it difficult to understand any limitations of the server configuration. This script can display relevant information to help you understand what is happening behind the scenes.</p>
<div class="codesnip-container" >&lt;?php<br />
        $d_func = ini_get(&#8220;disable_functions&#8221;);<br />
        $up_max =  ini_get(&#8220;upload_max_filesize&#8221;);<br />
        $up_max = str_replace(&#8220;M&#8221;,&#8221;",$up_max);<br />
        $up_max_size = &#8220;Megabytes&#8221;;<br />
        $post_max = ini_get(&#8220;post_max_size&#8221;);<br />
        $post_max = str_replace(&#8220;M&#8221;,&#8221;",$post_max);<br />
        $post_max_size = &#8220;Megabytes&#8221;;<br />
        $input_max = ini_get(&#8220;max_input_time&#8221;);<br />
        $mem_limit = ini_get(&#8220;memory_limit&#8221;);<br />
        $mem_limit = str_replace(&#8220;M&#8221;,&#8221;",$mem_limit);<br />
        $mem_limit_size = &#8220;Megabytes&#8221;;<br />
        $exec_time = ini_get(&#8220;max_execution_time&#8221;);<br />
        $safe_mode = ini_get(&#8220;safe_mode&#8221;);</p>
<p>        if(!is_null($d_func) &#038;&#038; $d_func !== &#8220;&#8221;){echo  &#8220;Disabled Functions: \n $d_func&#8221;;}<br />
        if(!is_null($safe_mode) &#038;&#038; $safe_mode !== &#8220;&#8221;){echo  &#8220;&lt;span style=&#8217;color:red;&#8217;&gt;Safe Mode is Active&lt;/span&gt; &lt;br&gt;&#8221;;}<br />
        if($up_max >= 1001){$up_max = $up_max / 1024; $up_max_size = &#8220;Gigabytes&#8221;;<br />
        if($up_max >= 10001){$up_max = $up_max / 1024; $up_max_size = &#8220;Terabytes&#8221;;}}<br />
        if($post_max >= 1001){$post_max = $post_max / 1024; $post_max_size = &#8220;Gigabytes&#8221;;<br />
        if($post_max >= 10001){$post_max = $post_max / 1024;$post_max_size = &#8220;Terabytes&#8221;;}}<br />
        if (min($input_max,60)){$input_max = $input_max /60;}<br />
        if (min($exec_time,60)){$exec_time = $exec_time /60;}<br />
        if($mem_limit >= 1001){$mem_limit = $mem_limit / 1024; $mem_limit_size = &#8220;Gigabytes&#8221;;}</p>
<p>        echo &#8220;Maximum Upload Size = $up_max $up_max_size&lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Post Size = $post_max $post_max_size &lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Input Time = $input_max minute/s&lt;br&gt;&#8221;;<br />
        echo &#8220;Memory Limit = $mem_limit $mem_limit_size&lt;br&gt;&#8221;;<br />
        echo &#8220;Maximum Execution Time = $exec_time minute/s&lt;br&gt;&#8221;;<br />
?&gt;</p></div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/php-host-settings-without-phpinfo/652/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Modulo Operator For Alternating Rows</title>
		<link>http://boolean.co.nz/blog/modulo-alternating-rows/647/</link>
		<comments>http://boolean.co.nz/blog/modulo-alternating-rows/647/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 22:24:50 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=647</guid>
		<description><![CDATA[Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td>
<img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Alternating row colours within a grid of data can make for a more pleasant viewing experience and has become a popular styling method in recent times. I was a little incredulous at some code I saw recently to determine alternating rows so without further introduction, meet the Modulo operator which is a quick and easy way to get up and running:</p>
<div class="codesnip-container" >for($i=0;$i<10;$i++){<br />
  if($i % 2){<br />
   // This is an even row<br />
  }else{<br />
   // This is an odd row<br />
  }<br />
}</div>
<p>I&#8217;m sure you will be able to apply this to your own css or styling within your loops.</p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/modulo-alternating-rows/647/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Use cURL to obtain remote filesize</title>
		<link>http://boolean.co.nz/blog/curl-remote-filesize/638/</link>
		<comments>http://boolean.co.nz/blog/curl-remote-filesize/638/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 11:00:46 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=638</guid>
		<description><![CDATA[Sometimes you might want to determine a remote file size prior to determining further action to take. This is a quick function that utilises cURL to retrieve the file size in bytes. &#60;?php function remoteFilesize ($URL){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $info = curl_exec($ch); curl_close($ch); [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Sometimes you might want to determine a remote file size prior to determining further action to take. This is a quick function that utilises cURL to retrieve the file size in bytes.</p>
<div class="codesnip-container" >&lt;?php<br />
function remoteFilesize ($URL){<br />
	$ch = curl_init();<br />
	curl_setopt($ch, CURLOPT_URL, $URL);<br />
	curl_setopt($ch, CURLOPT_HEADER, true);<br />
	curl_setopt($ch, CURLOPT_NOBODY, true);<br />
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);<br />
	$info = curl_exec($ch);<br />
	curl_close($ch);<br />
	$info = explode(&#8216;Content-Length:&#8217;, $info);<br />
	$info = explode(&#8220;Connection&#8221;,$info[1]);<br />
	return $info[0];<br />
}<br />
?&gt;</div>
<p>Usage is simple:</p>
<div class="codesnip-container" >echo remoteFilesize(&#8220;test.com/file.html&#8221;);</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/curl-remote-filesize/638/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Get Facebook Likes and Shares via Graph API</title>
		<link>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/</link>
		<comments>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/#comments</comments>
		<pubDate>Sun, 11 Sep 2011 01:46:44 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[FaceBook]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=626</guid>
		<description><![CDATA[Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements. &#60;?php $URL =&#8217;https://graph.facebook.com/cocacola&#8217;; $JSON = file_get_contents($URL); $Output = json_decode($JSON); $Likes = 0; if($Output->likes){ &#160;&#160;$Likes = $Output->likes; [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" />
<td></tr>
</table>
<p>Facebook Like and Share count can easily be obtained from the Facebook Graph API. This is an extremely quick way to look up the JSON response from Facebook so that you can further process it for your own requirements.</p>
<div class="codesnip-container" >&lt;?php<br />
$URL =&#8217;https://graph.facebook.com/cocacola&#8217;;<br />
$JSON = file_get_contents($URL);<br />
$Output = json_decode($JSON);<br />
$Likes = 0;<br />
if($Output->likes){<br />
&nbsp;&nbsp;$Likes = $Output->likes;<br />
}</p>
<p>echo &#8220;Number of likes for CocaCola&#8217;s Facebook Page = &#8220;.$Likes.&#8221;&lt;/br&gt;&#8221;;</p>
<p>$URL2 =&#8217;https://graph.facebook.com/http://www.coca-cola.com&#8217;;<br />
$JSON2 = file_get_contents($URL2);<br />
$Output2 = json_decode($JSON2);<br />
$Shares = 0;<br />
if($Output2->shares){<br />
&nbsp;&nbsp;$Shares = $Output2->shares;<br />
}</p>
<p>echo &#8220;Number of shares for coca-cola.com = &#8220;.$Shares;<br />
?&gt;</p></div>
<p><strong>UPDATE 29/01/2012:</strong> I&#8217;ve written a slightly different method using the PHP SDK in this post <a href="http://boolean.co.nz/blog/facebook-likes-sdk/713" title="here" target="_blank">here</a></p>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/get-facebook-likes-and-shares-via-graph-api/626/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Currency Conversion using Yahoo Finance API</title>
		<link>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/</link>
		<comments>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/#comments</comments>
		<pubDate>Sat, 10 Sep 2011 00:54:08 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=622</guid>
		<description><![CDATA[Just a quick and dirty PHP function to retrieve information from the Yahoo Finance API to perform a currency conversion function ConvertCurrency($From,$To,$Amount){ $URL = &#8216;http://finance.yahoo.com/d/quotes.csv?e=.csv&#038;f=sl1d1t1&#038;s=&#8217;. $From . $To .&#8217;=X&#8217;; $Handle = @fopen($URL, &#8216;r&#8217;); if ($Handle) { $Result = fgets($Handle, 4096); fclose($Handle); } $allData = explode(&#8216;,&#8217;,$Result); $Value = $allData[1]; return $Value * $Amount; } Usage: $Amount [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Just a quick and dirty PHP function to retrieve information from the Yahoo Finance API to perform a currency conversion</p>
<div class="codesnip-container" >function ConvertCurrency($From,$To,$Amount){<br />
	$URL = &#8216;http://finance.yahoo.com/d/quotes.csv?e=.csv&#038;f=sl1d1t1&#038;s=&#8217;. $From . $To .&#8217;=X&#8217;;<br />
	$Handle = @fopen($URL, &#8216;r&#8217;);</p>
<p>	if ($Handle) {<br />
    	$Result = fgets($Handle, 4096);<br />
    	fclose($Handle);<br />
	}<br />
	$allData = explode(&#8216;,&#8217;,$Result);<br />
	$Value = $allData[1];</p>
<p>	return $Value * $Amount;<br />
}</p></div>
<p>Usage:</p>
<div class="codesnip-container" >$Amount = ConvertCurrency(&#8220;NZD&#8221;,&#8221;USD&#8221;,25);</div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/currency-conversion-using-yahoo-finance-api/622/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Script Execution Timer Class</title>
		<link>http://boolean.co.nz/blog/php-script-execution-timer-class/553/</link>
		<comments>http://boolean.co.nz/blog/php-script-execution-timer-class/553/#comments</comments>
		<pubDate>Wed, 23 Mar 2011 06:45:21 +0000</pubDate>
		<dc:creator>Boolean</dc:creator>
				<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://boolean.co.nz/blog/?p=553</guid>
		<description><![CDATA[Often for testing the efficieny of some PHP code we use script execution calculations such as the microtime function. What is infinitely more useful however is the ability to time the execution of all, some, or multiple sections of code or series of lines. Unfortunately I cant remember the origins of this timer class &#8211; [...]]]></description>
			<content:encoded><![CDATA[<table>
<tr>
<td><img src="http://boolean.co.nz/blog/wp-content/uploads/2009/03/php-logo.png" alt="" title="php-logo" width="203" height="107" class="aligncenter size-full wp-image-61" /></td>
</tr>
</table>
<p>Often for testing the efficieny of some PHP code we use script execution calculations such as the <a href="http://php.net/manual/en/function.microtime.php">microtime</a> function. What is infinitely more useful however is the ability to time the execution of all, some, or multiple sections of code or series of lines.<br />
Unfortunately I cant remember the origins of this timer class &#8211; but this code allows you to stop, start, pause and resume timing of specific sections of your php code. Thank you, whoever you may be.</p>
<p>Download the class <a href="http://boolean.co.nz/resources/files/examples/timer.zip">here</a></p>
<p>Available methods:</p>
<p><strong>start()</strong> &#8211; start/resume the timer<br />
<strong>stop()</strong> &#8211; stop/pause the timer<br />
<strong>reset()</strong> &#8211; reset the timer<br />
<strong>get</strong>([$format]) Which can defaults to Timer::SECONDS but can also be Timer::MILLISECONDS or Timer::MICROSECONDS</p>
<p>Usage example:</p>
<div class="codesnip-container" >$timer1 = new Timer();<br />
$timer2 = new Timer();</p>
<p>$timer1->start();<br />
// do some code</p>
<p>// calculate the time it takes to run a function<br />
$timer2->start();<br />
functionX();<br />
$timer2->stop();</p>
<p>$timer1->stop();</p>
<p>print $timer1->get();<br />
print $timer2->get();</p></div>
]]></content:encoded>
			<wfw:commentRss>http://boolean.co.nz/blog/php-script-execution-timer-class/553/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

