<?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>Werx Limited &#187; wkt</title> <atom:link href="http://werxltd.com/wp/tag/wkt/feed/" rel="self" type="application/rss+xml" /><link>http://werxltd.com/wp</link> <description>We make IT work.</description> <lastBuildDate>Mon, 23 Jan 2012 23:03:59 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>Using PHP to write PHP</title><link>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/</link> <comments>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/#comments</comments> <pubDate>Thu, 29 Jul 2010 19:00:49 +0000</pubDate> <dc:creator>wes</dc:creator> <category><![CDATA[php]]></category> <category><![CDATA[kml]]></category> <category><![CDATA[mapping]]></category> <category><![CDATA[utilities]]></category> <category><![CDATA[wkt]]></category><guid
isPermaLink="false">http://werxltd.com/wp/?p=630</guid> <description><![CDATA[I ran into a situation recently where I had a very large array object that was not going to change. It was the polygon coordinates for the world countries to be used in KML provided by Thematic Mapping. I didn&#8217;t wan&#8217;t to pull this data out of MySQL every time I went to build a [...]]]></description> <content:encoded><![CDATA[<p>I ran into a situation recently where I had a very large array object that was not going to change. It was the polygon coordinates for the world countries to be used in <a
href="http://code.google.com/apis/kml/documentation/">KML</a> provided by <a
href="http://thematicmapping.org/">Thematic Mapping</a>.</p><p>I didn&#8217;t wan&#8217;t to pull this data out of MySQL every time I went to build a map, I wanted to use one giant static array instead. So to write the array back out in a re-usable fashion I developed the following code which can take any array, of any depth, associative or index based, and spit out corresponding PHP that you can copy and paste back into your script.</p><pre class="brush:php">function phpPrintArr(array $arr) {
	echo "array(".PHP_EOL;

	$c = 1;
	$total = count($arr);

	foreach($arr as $i =&gt;$v) {
		$iq = is_numeric($i) ? '' : '"';
		$vq = is_numeric($v) ? '' : '"';
		$e = $c &lt; $total ? ',' : '';

		if(is_array($v)) {
			echo $iq.$i.$iq.'=&gt;'.PHP_EOL;
			phpPrintArr($v);
			echo $e.PHP_EOL;
		} else {
			echo $iq.$i.$iq.'=&gt;'.$vq.$v.$vq.$e.PHP_EOL;
		}
		$c++;
	}

	echo ")".PHP_EOL;
}</pre><p>Oh, and for anyone who is interested in the array of country polygons this produced from the Thematic Mapping Engine data, <a
href="http://werxltd.com/software/TME_Countries">here is the rather large array</a>. Feel free to use it in your own KML project.</p><div
class="betterrelated none"><p>No related content found.</p></div><p><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service facebook_like" src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;layout=button_count&amp;show_faces=false&amp;width=75&amp;action=like&amp;colorscheme=light&amp;height=20&amp;ref=addtoany" scrolling="no" style="border:none;overflow:hidden;width:90px;height:21px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;count=none&amp;text=Using%20PHP%20to%20write%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service twitter_tweet" src="http://platform.twitter.com/widgets/tweet_button.html?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;counturl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;count=none&amp;text=Using%20PHP%20to%20write%20PHP" scrolling="no" style="border:none;overflow:hidden;width:55px;height:20px"></iframe><!--<![endif]--><!--[if IE]><iframe
frameborder="0" allowTransparency="true" class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><![endif]--><!--[if !IE]><!--><iframe
class="addtoany_special_service google_plusone" src="https://plusone.google.com/u/0/_/%2B1/fastbutton?url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;size=medium&amp;count=false" scrolling="no" style="border:none;overflow:hidden;width:32px;height:20px"></iframe><!--<![endif]--><a
class="a2a_button_linkedin" href="http://www.addtoany.com/add_to/linkedin?linkurl=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;linkname=Using%20PHP%20to%20write%20PHP" title="LinkedIn" rel="nofollow" target="_blank"><img
src="http://werxltd.com/wp/wp-content/plugins/add-to-any/icons/linkedin.png?9d7bd4" width="16" height="16" alt="LinkedIn"/></a><a
class="a2a_dd a2a_target addtoany_share_save" href="http://www.addtoany.com/share_save#url=http%3A%2F%2Fwerxltd.com%2Fwp%2F2010%2F07%2F29%2Fusing-php-to-write-php%2F&amp;title=Using%20PHP%20to%20write%20PHP" id="wpa2a_2">Share/Save</a></p>]]></content:encoded> <wfw:commentRss>http://werxltd.com/wp/2010/07/29/using-php-to-write-php/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using apc
Page Caching using apc
Database Caching 1/19 queries in 0.233 seconds using apc
Object Caching 316/357 objects using apc

Served from: werxltd.com @ 2012-02-08 13:31:37 -->
