<?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>Blog of Travis Hydzik &#187; php</title>
	<atom:link href="http://thydzik.com/tag/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://thydzik.com</link>
	<description>random snippets and information</description>
	<lastBuildDate>Mon, 30 Apr 2012 15:46:07 +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>RegexBuddy &#8211; a solution to the Regular Expressions (Regex) nightmare</title>
		<link>http://thydzik.com/regexbuddy-a-solution-to-the-regular-expressions-regex-nightmare/</link>
		<comments>http://thydzik.com/regexbuddy-a-solution-to-the-regular-expressions-regex-nightmare/#comments</comments>
		<pubDate>Thu, 15 Dec 2011 04:54:38 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Reviews]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[RegexBuddy]]></category>
		<category><![CDATA[regular expression]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=836</guid>
		<description><![CDATA[For the last few months I have been using RegexBuddy, software designed to help with Regular Expressions. After using it to create and test more than one extremely complex regular expression, I thought it was time I gave RegexBuddy some ‘big ups’. So what is so good about RegexBuddy, Firstly, it allows you to create [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/regexbuddy-a-solution-to-the-regular-expressions-regex-nightmare/' addthis:title='RegexBuddy &#8211; a solution to the Regular Expressions (Regex) nightmare ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>For the last few months I have been using <a title="RegexBuddy website" href="http://www.regexbuddy.com/" target="_blank">RegexBuddy</a>, software designed to help with Regular Expressions.</p>
<p>After using it to create and test more than one extremely complex regular expression, I thought it was time I gave RegexBuddy some ‘big ups’.</p>
<p>So what is so good about <a title="RegexBuddy website" href="http://www.regexbuddy.com/" target="_blank">RegexBuddy</a>,</p>
<p><span style="text-decoration: underline;">Firstly</span>, it allows you to create regular expressions using layman’s terms, “Non printable character”, “Match between zero and unlimited times”, “Create back-reference”, etc, no longer is there a need to remember the regular expression syntax.</p>
<p><span style="text-decoration: underline;">Secondly</span>, I can test my regular expression with extreme ease, I can show the full matched text and any matched groupings.</p>
<p><span style="text-decoration: underline;">Thirdly</span>, I can directly translate the regular expression to the programming language of choice, VB, PHP, JavaScript, etc, and not have to worry about the specifics of how to form a regular expression for that specific language.</p>
<p>I use RegexBuddy for PHP and JavaScript, I no longer need to ‘guess’ what the regular expression will be and constantly have to upload my code to the server to try it out.</p>
<p>Here’s an example expression I recently used in my WordPress plugin <a title="Slimbox2 Slideshow WordPress plugin" href="http://thydzik.com/category/slimbox2-slideshow/" target="_blank">Slimbox2 Slideshow</a>;</p>
<p><iframe frameborder="0" src="http://thydzik.com/downloads/regexbuddy-example.htm" width="450" height="1000" scrolling="no"></iframe></p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/regexbuddy-a-solution-to-the-regular-expressions-regex-nightmare/' addthis:title='RegexBuddy &#8211; a solution to the Regular Expressions (Regex) nightmare ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/regexbuddy-a-solution-to-the-regular-expressions-regex-nightmare/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert from Google KML to GPS Exchange Format GPX with PHP</title>
		<link>http://thydzik.com/convert-from-google-kml-to-gps-exchange-format-gpx/</link>
		<comments>http://thydzik.com/convert-from-google-kml-to-gps-exchange-format-gpx/#comments</comments>
		<pubDate>Wed, 26 Oct 2011 17:58:50 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Geocaching]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[convert]]></category>
		<category><![CDATA[Google]]></category>
		<category><![CDATA[GPS]]></category>
		<category><![CDATA[GPX]]></category>
		<category><![CDATA[KML]]></category>
		<category><![CDATA[Map]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=740</guid>
		<description><![CDATA[Here is a quick post on converting from KML files used in Google Earth/Maps to GPX Exchange Format (GPX) with PHP. Code is quite explanatory, change $u with the location of the KML file, code will output GPX XML. Alternatively, download the code here. Let me know if you find any issues.<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/convert-from-google-kml-to-gps-exchange-format-gpx/' addthis:title='Convert from Google KML to GPS Exchange Format GPX with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Here is a quick post on converting from KML files used in Google Earth/Maps to GPX Exchange Format (GPX) with PHP.</p>
<p>Code is quite explanatory, change <em>$u</em> with the location of the KML file, code will output GPX XML.</p>
<p><a href="http://thydzik.com/downloads/kml-to-gpx.php.txt" title="Download PHP code to covert KML to GPX" target="_blank">Alternatively, download the code here.</a></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	//enter location of KML file here
	$u = &quot;http://code.google.com/apis/kml/documentation/KML_Samples.kml&quot;;

	function utcdate() {
		return gmdate(&quot;Y-m-d\Th:i:s\Z&quot;);
	}

	$u_parts = pathinfo($u); //array of url parts
	$u_ext = strtoupper($u_parts['extension']);
	if ($u_ext== &quot;KML&quot;) {

		$dom_kml = new DOMDocument();
		$dom_kml-&gt;load($u);

		$dom_gpx = new DOMDocument('1.0', 'UTF-8');
		$dom_gpx-&gt;formatOutput = true;

		//root node
		$gpx = $dom_gpx-&gt;createElement('gpx');
		$gpx = $dom_gpx-&gt;appendChild($gpx);

		$gpx_version = $dom_gpx-&gt;createAttribute('version');
		$gpx-&gt;appendChild($gpx_version);
		$gpx_version_text = $dom_gpx-&gt;createTextNode('1.0');
		$gpx_version-&gt;appendChild($gpx_version_text);

		$gpx_creator = $dom_gpx-&gt;createAttribute('creator');
		$gpx-&gt;appendChild($gpx_creator);
		$gpx_creator_text = $dom_gpx-&gt;createTextNode('http://thydzik.com');
		$gpx_creator-&gt;appendChild($gpx_creator_text);

		$gpx_xmlns_xsi = $dom_gpx-&gt;createAttribute('xmlns:xsi');
		$gpx-&gt;appendChild($gpx_xmlns_xsi);
		$gpx_xmlns_xsi_text = $dom_gpx-&gt;createTextNode('http://www.w3.org/2001/XMLSchema-instance');
		$gpx_xmlns_xsi-&gt;appendChild($gpx_xmlns_xsi_text);

		$gpx_xmlns = $dom_gpx-&gt;createAttribute('xmlns');
		$gpx-&gt;appendChild($gpx_xmlns);
		$gpx_xmlns_text = $dom_gpx-&gt;createTextNode('http://www.topografix.com/GPX/1/0');
		$gpx_xmlns-&gt;appendChild($gpx_xmlns_text);

		$gpx_xsi_schemaLocation = $dom_gpx-&gt;createAttribute('xsi:schemaLocation');
		$gpx-&gt;appendChild($gpx_xsi_schemaLocation);
		$gpx_xsi_schemaLocation_text = $dom_gpx-&gt;createTextNode('http://www.topografix.com/GPX/1/0 http://www.topografix.com/GPX/1/0/gpx.xsd');
		$gpx_xsi_schemaLocation-&gt;appendChild($gpx_xsi_schemaLocation_text);

		$gpx_url = $dom_gpx-&gt;createElement('url');
		$gpx_url = $gpx-&gt;appendChild($gpx_url);
		$gpx_url_text = $dom_gpx-&gt;createTextNode($u_parts['dirname']);
		$gpx_url-&gt;appendChild($gpx_url_text);

		$gpx_time = $dom_gpx-&gt;createElement('time');
		$gpx_time = $gpx-&gt;appendChild($gpx_time);
		$gpx_time_text = $dom_gpx-&gt;createTextNode(utcdate());
		$gpx_time-&gt;appendChild($gpx_time_text);

		// placemarks
		$names = array();
		foreach ($dom_kml-&gt;getElementsByTagName('Placemark') as $placemark) {
			//name
			foreach ($placemark-&gt;getElementsByTagName('name') as $name) {
				$name  = $name-&gt;nodeValue;
				//check if the key exists
				if (array_key_exists($name, $names)) {
					//increment the value
					++$names[$name];
					$name = $name.&quot; ({$names[$name]})&quot;;
				} else {
					$names[$name] = 0;
				}
			}
			//description
			foreach ($placemark-&gt;getElementsByTagName('description') as $description) {
				$description  = $description-&gt;nodeValue;
			}
			foreach ($placemark-&gt;getElementsByTagName('Point') as $point) {
				foreach ($point-&gt;getElementsByTagName('coordinates') as $coordinates) {
					//add the marker
					$coordinate = $coordinates-&gt;nodeValue;
					$coordinate = str_replace(&quot; &quot;, &quot;&quot;, $coordinate);//trim white space
					$latlng = explode(&quot;,&quot;, $coordinate);

					if (($lat = $latlng[1]) &amp;&amp; ($lng = $latlng[0])) {
						$gpx_wpt = $dom_gpx-&gt;createElement('wpt');
						$gpx_wpt = $gpx-&gt;appendChild($gpx_wpt);

						$gpx_wpt_lat = $dom_gpx-&gt;createAttribute('lat');
						$gpx_wpt-&gt;appendChild($gpx_wpt_lat);
						$gpx_wpt_lat_text = $dom_gpx-&gt;createTextNode($lat);
						$gpx_wpt_lat-&gt;appendChild($gpx_wpt_lat_text);

						$gpx_wpt_lon = $dom_gpx-&gt;createAttribute('lon');
						$gpx_wpt-&gt;appendChild($gpx_wpt_lon);
						$gpx_wpt_lon_text = $dom_gpx-&gt;createTextNode($lng);
						$gpx_wpt_lon-&gt;appendChild($gpx_wpt_lon_text);

						$gpx_time = $dom_gpx-&gt;createElement('time');
						$gpx_time = $gpx_wpt-&gt;appendChild($gpx_time);
						$gpx_time_text = $dom_gpx-&gt;createTextNode(utcdate());
						$gpx_time-&gt;appendChild($gpx_time_text);

						$gpx_name = $dom_gpx-&gt;createElement('name');
						$gpx_name = $gpx_wpt-&gt;appendChild($gpx_name);
						$gpx_name_text = $dom_gpx-&gt;createTextNode($name);
						$gpx_name-&gt;appendChild($gpx_name_text);

						$gpx_desc = $dom_gpx-&gt;createElement('desc');
						$gpx_desc = $gpx_wpt-&gt;appendChild($gpx_desc);
						$gpx_desc_text = $dom_gpx-&gt;createTextNode($description);
						$gpx_desc-&gt;appendChild($gpx_desc_text);

						//$gpx_url = $dom_gpx-&gt;createElement('url');
						//$gpx_url = $gpx_wpt-&gt;appendChild($gpx_url);
						//$gpx_url_text = $dom_gpx-&gt;createTextNode($ref);
						//$gpx_url-&gt;appendChild($gpx_url_text);

						$gpx_sym = $dom_gpx-&gt;createElement('sym');
						$gpx_sym = $gpx_wpt-&gt;appendChild($gpx_sym);
						$gpx_sym_text = $dom_gpx-&gt;createTextNode('Waypoint');
						$gpx_sym-&gt;appendChild($gpx_sym_text);
					}
				}
			}
			foreach ($placemark-&gt;getElementsByTagName('LineString') as $lineString) {
				foreach ($lineString-&gt;getElementsByTagName('coordinates') as $coordinates) {
					//add the new track
					$gpx_trk = $dom_gpx-&gt;createElement('trk');
					$gpx_trk = $gpx-&gt;appendChild($gpx_trk);

					$gpx_name = $dom_gpx-&gt;createElement('name');
					$gpx_name = $gpx_trk-&gt;appendChild($gpx_name);
					$gpx_name_text = $dom_gpx-&gt;createTextNode($name);
					$gpx_name-&gt;appendChild($gpx_name_text);

					$gpx_trkseg = $dom_gpx-&gt;createElement('trkseg');
					$gpx_trkseg = $gpx_trk-&gt;appendChild($gpx_trkseg);

					$coordinates = $coordinates-&gt;nodeValue;
					$coordinates = preg_split(&quot;/[\s\r\n]+/&quot;, $coordinates); //split the coords by new line
					foreach ($coordinates as $coordinate) {
						$latlng = explode(&quot;,&quot;, $coordinate);

						if (($lat = $latlng[1]) &amp;&amp; ($lng = $latlng[0])) {
							$gpx_trkpt = $dom_gpx-&gt;createElement('trkpt');
							$gpx_trkpt = $gpx_trkseg-&gt;appendChild($gpx_trkpt);

							$gpx_trkpt_lat = $dom_gpx-&gt;createAttribute('lat');
							$gpx_trkpt-&gt;appendChild($gpx_trkpt_lat);
							$gpx_trkpt_lat_text = $dom_gpx-&gt;createTextNode($lat);
							$gpx_trkpt_lat-&gt;appendChild($gpx_trkpt_lat_text);

							$gpx_trkpt_lon = $dom_gpx-&gt;createAttribute('lon');
							$gpx_trkpt-&gt;appendChild($gpx_trkpt_lon);
							$gpx_trkpt_lon_text = $dom_gpx-&gt;createTextNode($lng);
							$gpx_trkpt_lon-&gt;appendChild($gpx_trkpt_lon_text);

							$gpx_time = $dom_gpx-&gt;createElement('time');
							$gpx_time = $gpx_trkpt-&gt;appendChild($gpx_time);
							$gpx_time_text = $dom_gpx-&gt;createTextNode(utcdate());
							$gpx_time-&gt;appendChild($gpx_time_text);
						}
					}
				}
			}
		}
		header(&quot;Content-Type: text/xml&quot;);
		echo $dom_gpx-&gt;saveXML();
	}
?&gt;
</pre>
<p>Let me know if you find any issues.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/convert-from-google-kml-to-gps-exchange-format-gpx/' addthis:title='Convert from Google KML to GPS Exchange Format GPX with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/convert-from-google-kml-to-gps-exchange-format-gpx/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert Relative Links to Absolute Links with PHP Regex</title>
		<link>http://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/</link>
		<comments>http://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/#comments</comments>
		<pubDate>Sun, 23 Oct 2011 06:27:36 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Absolute]]></category>
		<category><![CDATA[links]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Regex]]></category>
		<category><![CDATA[Relative]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=731</guid>
		<description><![CDATA[Here is a quick post on how to find and replace relative links with absolute links using PHP Regular Expressions (regex).<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/' addthis:title='Convert Relative Links to Absolute Links with PHP Regex ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Here is a quick post on how to find and replace relative links with absolute links using PHP Regular Expressions (regex).</p>
<pre class="brush: php; title: ; notranslate">
$url = &quot;http://myabsoluteurl.com/&quot;;
$ret = preg_replace('/((?:href|src) *= *[\'&quot;](?!(http|ftp)))/i', &quot;$1$url&quot;, $ret);
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/' addthis:title='Convert Relative Links to Absolute Links with PHP Regex ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/convert-relative-links-to-absolute-links-with-php-regex/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Online RSVP form and database with PHP, JavaScript and MySQL</title>
		<link>http://thydzik.com/online-rsvp-form-and-database-with-php-javascript-and-mysql/</link>
		<comments>http://thydzik.com/online-rsvp-form-and-database-with-php-javascript-and-mysql/#comments</comments>
		<pubDate>Fri, 30 Sep 2011 05:53:56 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Random]]></category>
		<category><![CDATA[form]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[online]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[reception]]></category>
		<category><![CDATA[RSVP]]></category>
		<category><![CDATA[wedding]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=670</guid>
		<description><![CDATA[Requirements Recently, I needed an online RSVP system for a reception I was hosting, all the options out there didn&#8217;t meet my requirements; Customisable and able to self-host No need for tracking codes/numbers to be sent with invitation Able to RSVP additional guests Able to modify an existing RSVP Implementation As usual, I decided to [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/online-rsvp-form-and-database-with-php-javascript-and-mysql/' addthis:title='Online RSVP form and database with PHP, JavaScript and MySQL ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p><strong>Requirements</strong></p>
<p>Recently, I needed an online RSVP system for a reception I was hosting, all the options out there didn&#8217;t meet my requirements;</p>
<ul>
<li>Customisable and able to self-host</li>
<li>No need for tracking codes/numbers to be sent with invitation</li>
<li>Able to RSVP additional guests</li>
<li>Able to modify an existing RSVP</li>
</ul>
<p><strong>Implementation</strong></p>
<div>As usual, I decided to implement my own online RSVP solution, which has the following functionality;</div>
<div>
<ul>
<li>PHP/JavaScript front-end</li>
<li>MySQL back-end</li>
<li>Sleek CSS (borrowed from WordPress)</li>
<li>Client-side checking with JavaScript</li>
<li>Server-side checking with PHP</li>
<li>Very basic submission viewing in HTML, wasn&#8217;t a real requirement as I could browse the database with phpMyAdmin, but it was good to have some visibility without the need of logging in</li>
</ul>
<p><strong>Installation</strong></p>
<ul>
<li>You will need <a title="PHP website" href="http://www.php.net/">PHP</a> installed and a <a title="MySQL website" href="http://www.mysql.com/">MySQL</a> database.</li>
<li>Import the following <a title="SQL table create query" href="http://thydzik.com/downloads/rsvp-table-create.sql">SQL query</a> to create a RSVP table with required fields.</li>
<li>Create a folder on your web hosting.</li>
<li>Extract the following <a title="Self hosting files" href="http://thydzik.com/downloads/rsvp-thydzik.zip">zip file</a> contents to this newly created folder.</li>
<li>Edit rsvp.php and configure your database settings, including database name, user name, password and host.</li>
<li>If using the optional email confirmation, configure the email from address and email body contents.</li>
<li>On your website, create an iframe to show the RSVP form.</li>
</ul>
<div><strong>Testing</strong></div>
<div>
<ul>
<li>Navigate to <a title="RSVP form" href="http://thydzik.com/rsvp/rsvp.php">rsvp.php</a> and submit a test response.</li>
<li>Navigate to <a title="View responses" href="http://thydzik.com/rsvp/res.php">res.php</a> and confirm you can see your test response.</li>
<li>Alternatively, view the MySQL table directly (with phpMyAdmin)</li>
</ul>
</div>
<div><strong>Downloads</strong></div>
<div>
<ul>
<li><a title="SQL table create query" href="http://thydzik.com/downloads/rsvp-table-create.sql">SQL query to create a RSVP table</a></li>
<li><a title="Self hosting files" href="http://thydzik.com/downloads/rsvp-thydzik.zip">Zip file of files to host</a></li>
</ul>
<p><strong>Demo</strong></p>
</div>
<p><iframe frameborder="0" src="http://thydzik.com/rsvp/rsvp.php" width="450" height="1000" scrolling="no"></iframe></p>
<p><strong>Improvements</strong></p>
<p>Two small things I would have added, known after it&#8217;s use;</p>
<ul>
<li>Client-side checking for &#8216;and&#8217; in the full name field, few guests still tried to add themselves and their partner in that field.</li>
<li>Improved response email that would be addressed to all guests not just the first name.</li>
</ul>
</div>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/online-rsvp-form-and-database-with-php-javascript-and-mysql/' addthis:title='Online RSVP form and database with PHP, JavaScript and MySQL ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/online-rsvp-form-and-database-with-php-javascript-and-mysql/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Dynamic Google Maps circle markers/icons with PHP</title>
		<link>http://thydzik.com/dynamic-google-maps-circle-markersicons-with-php/</link>
		<comments>http://thydzik.com/dynamic-google-maps-circle-markersicons-with-php/#comments</comments>
		<pubDate>Fri, 04 Mar 2011 16:13:56 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Arial]]></category>
		<category><![CDATA[circle]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[markers]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symbols]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=580</guid>
		<description><![CDATA[A while back I posted on how to create dynamic Google maps markers which allow for any colour and any text in the classic Google map style. Recently, I have had a need to do the same with circular markers. It uses the &#8216;Image Smooth Arc&#8216; function provided by Ulrich Mierendorff. Similarly, I provide a [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/dynamic-google-maps-circle-markersicons-with-php/' addthis:title='Dynamic Google Maps circle markers/icons with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>A while back I posted on how to create <a href="http://thydzik.com/dynamic-google-maps-markersicons-with-php/">dynamic Google maps markers</a> which allow for any colour and any text in the classic Google map style.</p>
<p>Recently, I have had a need to do the same with circular markers. It uses the &#8216;<a href="http://mierendo.com/software/antialiased_arcs/">Image Smooth Arc</a>&#8216; function provided by Ulrich Mierendorff.</p>
<p>Similarly, I provide a little demo of some PHP code that does this that I quickly whipped up. Here are some example markers:<br />
<a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=A" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=Z" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=1" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=10" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=PQ" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=69" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=%BE" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=Ω" alt="Ω" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=$" alt="$" /></a><br />
(Have a look at the image name)</p>
<p>Now that gets a little boring, how about some <strong>color</strong>:<br />
<a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?color=fdabff" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=A&amp;color=c89bff" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=Z&amp;color=01bf00" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=1&amp;color=97ec7d" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=10&amp;color=6b98ff" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=PQ&amp;color=bce3ff" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=69&amp;color=ffed5c" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=%BE&amp;color=cb9d7c" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=Ω&amp;color=fd8d08" alt="Ω" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/cmarker.php?text=$&amp;color=ffffff" alt="$" /></a><br />
(Again, have a look at the image name)</p>
<p>Again, you will need to download the <a title="modifies arial font" href="http://thydzik.com/thydzikGoogleMap/arial.ttf" target="_blank">modified arial font</a> and host it in the same directory.</p>
<p>Have a look at the PHP source code below:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	include (&quot;imageSmoothArc_optimized.php&quot;);

	$color = $_GET['color'];
	if (!$color) {$color = &quot;ff776b&quot;;} //default google map color
	$color = str_replace(&quot;#&quot;, &quot;&quot;, $color);
	$string = $_GET['text'];

	$font = realpath('arial.ttf');

	//unfortunately we still must do some offsetting
	switch (ord(substr($string,0,1))) {
		case 49: //1
			$offset = -2;
			break;
		case 55: //7
			$offset = -1;
			break;
		case 65: //A
			$offset = 1;
			break;
		case 74: //J
			$offset = -1;
			break;
		case 84: //T
			$offset = 1;
			break;
		case 99: //c
			$offset = -1;
			break;
		case 106: //j
			$offset = 1;
			break;
	}
	if (strlen($string) == 1) {
		$fontsize = 10.5;
	} else if (strlen($string) == 2) {
		$fontsize = 9;
	} else {
		$fontsize = 10.5;
		$offset = 0; //reset offset
		$string = chr(149);
	}

	$bbox = imagettfbbox($fontsize, 0, $font, $string);
	$width = $bbox[2] - $bbox[0] + 1;
	$height = $bbox[1] - $bbox[7] + 1;

	$im = imagecreatetruecolor(20, 20);

	//add the alpha
	$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
	imagefill($im, 0, 0, $trans_colour);

	imageAlphaBlending($im, true);
	imageSaveAlpha($im, true);

	$bord_ellipse = array (0, 0, 0, 0);
	imageSmoothArc($im, 9, 10, 17, 17, $bord_ellipse, 0, 2*M_PI); //x, y, width, hegiht

	$fill_ellipse = array (hexdec(substr($color,0,2)), hexdec(substr($color,2,2)), hexdec(substr($color,4,2)), 0);
	imageSmoothArc($im, 9, 10, 16, 16, $fill_ellipse, 0, 2*M_PI); //x, y, width, hegiht

	$black = imagecolorallocate($im, 0, 0, 0);
	imagettftext($im, $fontsize, 0, 11 - $width/2 + $offset, 9 + $height/2, $black, $font, $string);

	header(&quot;Content-type: image/png&quot;);
	imagepng($im);
	imagedestroy($im);
?&gt;
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/dynamic-google-maps-circle-markersicons-with-php/' addthis:title='Dynamic Google Maps circle markers/icons with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/dynamic-google-maps-circle-markersicons-with-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>PHP Factorial and Combination functions</title>
		<link>http://thydzik.com/php-factorial-and-combination-functions/</link>
		<comments>http://thydzik.com/php-factorial-and-combination-functions/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 07:02:48 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[combination]]></category>
		<category><![CDATA[factorial]]></category>
		<category><![CDATA[functions]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[Probability]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=477</guid>
		<description><![CDATA[A quick post on two functions for PHP that provide factorial and combination support.<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/php-factorial-and-combination-functions/' addthis:title='PHP Factorial and Combination functions ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>A quick post on two functions for PHP that provide <a href="http://en.wikipedia.org/wiki/Factorial">factorial</a> and <a href="http://en.wikipedia.org/wiki/Combination">combination</a> support.</p>
<pre class="brush: php; title: ; notranslate">
function factorial($n) {
	if ($n &lt;= 1) {
		return 1;
	} else {
		return factorial($n - 1) * $n;
	}
}

function combinations($n, $k) {
	//note this defualts to 0 if $n &lt; $k
	if ($n &lt; $k) {
		return 0;
	} else {
		return factorial($n)/(factorial($k)*factorial(($n - $k)));
	}
}
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/php-factorial-and-combination-functions/' addthis:title='PHP Factorial and Combination functions ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/php-factorial-and-combination-functions/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>RSS feed aggregator/combiner in PHP with Magpie RSS (v2)</title>
		<link>http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/</link>
		<comments>http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 18:50:30 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[aggregator]]></category>
		<category><![CDATA[combiner]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[Feedcreator]]></category>
		<category><![CDATA[Magpie RSS]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[RSS feed]]></category>
		<category><![CDATA[title]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=373</guid>
		<description><![CDATA[I have recently upgraded the code to combine multiple RSS feeds, for the original version see this post. To install, extract the following zip file to a directory where you want your combined feeds to be displayed, I use thydzik.com/combinedfeed as thydizk.com/feed is already used by WordPress. Edit index.php for your site, and make sure [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/' addthis:title='RSS feed aggregator/combiner in PHP with Magpie RSS (v2) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I have recently upgraded the code to combine multiple RSS feeds, for the original version see <a title="RSS feed aggregator/combiner in PHP" href="http://thydzik.com/rss-feed-aggregatorcombiner-in-php/" target="_blank">this post</a>.</p>
<p>To install, extract the following zip file to a directory where you want your combined feeds to be displayed, I use <a title="New combined WordPress feeds" href="http://thydzik.com/combinedfeed/" target="_blank">thydzik.com/combinedfeed</a> as <a title="Original WordPress feed" href="http://thydzik.com/feed/" target="_blank">thydizk.com/feed</a> is already used by WordPress.</p>
<p>Edit index.php for your site, and make sure the <strong>temp directory has write permissions (mod 755)</strong>. That should be it. Enjoy.</p>
<p><a title="Download thydzik RSS feed aggregator v2.zip" href="http://thydzik.com/combinedfeed/thydzik-rss-feed-aggregator-v2.zip" target="_blank">thydzik RSS feed aggregator v2.zip</a></p>
<p>Thanks to <a title="Magpie RSS" href="http://magpierss.sourceforge.net/" target="_blank">Magpie RSS</a> and <a title="Feedcreator" href="http://sourceforge.net/projects/feedcreator/" target="_blank">Feedcreator</a>.</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	$TMP_ROOT = &quot;temp/&quot;; //a atempory folder for storing the cached feeds, need to have write access (mod755)
	$DOMAIN_NAME = &quot;http://thydzik.com/&quot;;
	$SITE_TITLE = &quot;Travis Hydzik's blog feeds&quot;;
	$SITE_DESRIPTION = &quot;A collection of Travis Hydzik's blog feeds&quot;;
	$SITE_AUTHOR = &quot;Travis Hydzik&quot;;

	$FEEDS_ARRAY  = array( //the collection of urls linking to individual feeds
		&quot;http://hydzik.com/feed/&quot;,
		&quot;http://sonyaandtravis.com/feed&quot;,
		&quot;http://thydzik.com/feed/&quot;
	);

	$MAX_ITEMS = 10;
	$SHOW_FULL_FEED = FALSE;

	//stop editing from here onwards

	define('MAGPIE_DIR', '');
	define('MAGPIE_CACHE_DIR', $TMP_ROOT);

	//include magpie rss http://magpierss.sourceforge.net/
	@require_once(MAGPIE_DIR.'rss_fetch.inc');

	//include universal feed creator http://sourceforge.net/projects/feedcreator/
	@include(MAGPIE_DIR.'feedcreator.class.php');

	//create the basic rss feed
	$rss = new UniversalFeedCreator();
	$rss-&gt;useCached();
	$rss-&gt;title = $SITE_TITLE;
	$rss-&gt;description = $SITE_DESRIPTION;
	$rss-&gt;link = $DOMAIN_NAME;
	$rss-&gt;syndicationURL = curPageURL();

	//get all items is all feeds
	$total_temp = 0; //temp total number of posts in all rss feeds
	foreach ($FEEDS_ARRAY as $single_url) {
		$array_temp[$single_url]['page_title'] = url_grab_title($single_url); //grab the page title

		$rss_temp = fetch_rss($single_url);
		$items = array_slice($rss_temp-&gt;items, 0, $MAX_ITEMS);
		$array_temp[$single_url]['rss_data'] = $items;
		$total_temp += count($items);

		$array_temp[$single_url]['rss_pointer'] = 0;

		preg_match('@^(?:http://)?([^/]+)@i', $single_url, $matches);
		$array_temp[$single_url]['site_url'] = $matches[0];
	}

	while ($total_temp &lt;&gt; 0 &amp;&amp; $MAX_ITEMS &gt; 0){// loop while there are remaining posts to process
		$date_timestamp_temp = 0; //initialise to 0
		foreach ($FEEDS_ARRAY as $single_url) {
			$this_date_timestamp = $array_temp[$single_url]['rss_data'][$array_temp[$single_url]['rss_pointer']]['date_timestamp']; //get the date stamp of this post
			if ($this_date_timestamp &gt; $date_timestamp_temp) { //if this date stamp is the newest, save where it came from
				$date_timestamp_temp = $this_date_timestamp; //update with this date stamp
				$temp_url = $single_url; //save the url feed
				$pointer_temp = $array_temp[$single_url]['rss_pointer']; //save the item number
			}
		}

		$total_temp --; //decrement total remaining posts to process
		$MAX_ITEMS --; //decrement number of posts to display
		$array_temp[$temp_url]['rss_pointer'] ++; //increment post index of used post rss

		//get the saved item
		$item = $array_temp[$temp_url]['rss_data'][$pointer_temp];

		//create the new item
		$item_new = new FeedItem();

		//add all the copied basics
		$item_new-&gt;title = $item['title'];
		$item_new-&gt;link = $item['link'];
		$item_new-&gt;date = $item['pubdate'];
		$item_new-&gt;author = $item['author'];
		$item_new-&gt;source = $temp_url;

		//to show full feed or blurb
		if ($SHOW_FULL_FEED) {
			$item_new-&gt;description = $item['content']['encoded'].'&lt;p&gt;Copyright &amp;copy; &lt;a href=&quot;'.$array_temp[$temp_url]['site_url'].'&quot;&gt;'.$array_temp[$temp_url]['page_title'].'&lt;/a&gt;. All Rights Reserved.&lt;/p&gt;';
		} else {
			$item_new-&gt;description = $item['description']       .'&lt;p&gt;Copyright &amp;copy; &lt;a href=&quot;'.$array_temp[$temp_url]['site_url'].'&quot;&gt;'.$array_temp[$temp_url]['page_title'].'&lt;/a&gt;. All Rights Reserved.&lt;/p&gt;';
		}

		$rss-&gt;addItem($item_new);
	}

	// a quick function the grab a pages title
	function url_grab_title($rss_url) {
  		$contents = file_get_contents($rss_url, TRUE, NULL, 0, 3072);
  		$contents = preg_replace(&quot;/(\n|\r)/&quot;, '', $contents);
		preg_match('/&lt;title&gt;(.*?)&lt;\/title&gt;/i', $contents, $matches);
		return $matches[1];
	}

	//get page url (for syndication), source http://www.webcheatsheet.com/PHP/get_current_page_url.php
	function curPageURL() {
		$pageURL = 'http';
		if ($_SERVER[&quot;HTTPS&quot;] == &quot;on&quot;) {$pageURL .= &quot;s&quot;;}
		$pageURL .= &quot;://&quot;;
		if ($_SERVER[&quot;SERVER_PORT&quot;] != &quot;80&quot;) {
			$pageURL .= $_SERVER[&quot;SERVER_NAME&quot;].&quot;:&quot;.$_SERVER[&quot;SERVER_PORT&quot;].$_SERVER[&quot;REQUEST_URI&quot;];
		} else {
			$pageURL .= $_SERVER[&quot;SERVER_NAME&quot;].$_SERVER[&quot;REQUEST_URI&quot;];
		}
		return $pageURL;
	}

	// get your news items from other feed and display back
	$rss-&gt;saveFeed(&quot;RSS2.0&quot;, $TMP_ROOT.&quot;feed.xml&quot;);
?&gt;
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/' addthis:title='RSS feed aggregator/combiner in PHP with Magpie RSS (v2) ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>thydzik Google Map v1.4.7 &#8211; inline WordPress Google Maps</title>
		<link>http://thydzik.com/thydzik-google-map-v147-inline-wordpress-google-maps/</link>
		<comments>http://thydzik.com/thydzik-google-map-v147-inline-wordpress-google-maps/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 02:48:53 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[thydzik Google Map]]></category>
		<category><![CDATA[FreeType]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[v1.7]]></category>
		<category><![CDATA[Wordpress]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=222</guid>
		<description><![CDATA[I have released an updated version of thydzik Google Map which allows for coloured and variable text markers, see the example below. google.maps.event.addDomListener(window, 'load', function () {thydzikgm('map222n1', 'aHR0cDovL3RoeWR6aWsuY29tL3dwLWNvbnRlbnQvcGx1Z2lucy90aHlkemlrLWdvb2dsZS1tYXAvZXhhbXBsZS54bWw=', -1, 'ROADMAP', 1, 'XML'); }); Unfortunately, it now requires FreeType being compiled into PHP. If FreeType is not installed only the default marker and markers A-Z will [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/thydzik-google-map-v147-inline-wordpress-google-maps/' addthis:title='thydzik Google Map v1.4.7 &#8211; inline WordPress Google Maps ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I have released an updated version of thydzik Google Map which allows for coloured and variable text markers, see the example below.</p>
<!--thydzikgooglemap-->
<div class='tgm_div' id='map222n1' style='width: 460px; height: 345px'></div>
<script type='text/javascript'>
google.maps.event.addDomListener(window, 'load', function () {thydzikgm('map222n1', 'aHR0cDovL3RoeWR6aWsuY29tL3dwLWNvbnRlbnQvcGx1Z2lucy90aHlkemlrLWdvb2dsZS1tYXAvZXhhbXBsZS54bWw=', -1, 'ROADMAP', 1, 'XML'); });
</script>
<!--/thydzikgooglemap-->

<p>Unfortunately, it now requires <a title="The FreeType Project" href="http://www.freetype.org/" target="_blank">FreeType</a> being compiled into PHP. If FreeType is not installed only the default marker and markers A-Z will be usable, with anything else being replaced with the default marker.</p>
<p>Download the latest from the <a title="WordPress Plugin Directory" href="http://wordpress.org/extend/plugins/thydzik-google-map/" target="_blank">WordPress Plugin Directory</a>.</p>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/thydzik-google-map-v147-inline-wordpress-google-maps/' addthis:title='thydzik Google Map v1.4.7 &#8211; inline WordPress Google Maps ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/thydzik-google-map-v147-inline-wordpress-google-maps/feed/</wfw:commentRss>
		<slash:comments>22</slash:comments>
		</item>
		<item>
		<title>Dynamic Google Maps markers/icons with PHP</title>
		<link>http://thydzik.com/dynamic-google-maps-markersicons-with-php/</link>
		<comments>http://thydzik.com/dynamic-google-maps-markersicons-with-php/#comments</comments>
		<pubDate>Thu, 26 Mar 2009 07:48:11 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Arial]]></category>
		<category><![CDATA[Dynamic]]></category>
		<category><![CDATA[Google Maps]]></category>
		<category><![CDATA[icons]]></category>
		<category><![CDATA[markers]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[symbols]]></category>

		<guid isPermaLink="false">http://thydzik.com/?p=205</guid>
		<description><![CDATA[I am a avid fan of Google&#8217;s Map API, have even have created my own WordPress Google Maps plug-in (thydzikGoogleMap), but one feature that I find lacking are customisable markers, with the need to include an image file for every customisable marker, now if you want a selection of colours and labels this creates a [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/dynamic-google-maps-markersicons-with-php/' addthis:title='Dynamic Google Maps markers/icons with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>I am a avid fan of Google&#8217;s Map API, have even have created my own WordPress Google Maps plug-in (<a title="thydzik Google Map plugin" href="http://thydzik.com/category/thydzikgooglemap/" target="_blank">thydzikGoogleMap</a>), but one feature that I find lacking are customisable markers, with the need to include an image file for every customisable marker, now if you want a selection of colours and labels this creates a huge image database.</p>
<p>Google has gone in the right step their <a title="Google Map Icon Maker" href="http://gmaps-utility-library.googlecode.com/svn/trunk/mapiconmaker/1.1/examples/markericonoptions-wizard.html" target="_blank">MapIconMaker</a> allowing very customisable markers using the Charts API marker output. But why not take this a step further and add dynamically generated <strong>text</strong> as well.</p>
<p>Hence, I provide a little demo of some PHP code that does this that I quickly whipped up. Here are some example markers:<br />
<a><img src="http://thydzik.com/thydzikGoogleMap/marker.php" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=A" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=Z" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=1" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=10" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=PQ" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=69" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=%BE" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=Ω" alt="Ω" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=$" alt="$" /></a><br />
(Have a look at the image name)</p>
<p>Now that gets a little boring, how about some <strong>color</strong>:<br />
<a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?color=fdabff" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=A&amp;color=c89bff" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=Z&amp;color=01bf00" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=1&amp;color=97ec7d" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=10&amp;color=6b98ff" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=PQ&amp;color=bce3ff" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=69&amp;color=ffed5c" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=%BE&amp;color=cb9d7c" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=Ω&amp;color=fd8d08" alt="Ω" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/marker.php?text=$&amp;color=ffffff" alt="$" /></a><br />
(Again, have a look at the image name)</p>
<p>Unfortunately, not all symbols work (not sure why, even though they are in the font) and if the symbol doesn&#8217;t work it will default to the default bullet (this is done with a modified font file).</p>
<p>Also there may be an issue with alignment. All main characters 0-9 and A-Z; I have added manual offsets, this could be improved.</p>
<p>You will need to download the <a title="modifies arial font" href="http://thydzik.com/thydzikGoogleMap/arial.ttf" target="_blank">modified arial font</a> and host it in the same directory.</p>
<p><strong>Update:</strong> it looks like in Internet Explorer the transparencies are incorrectly displayed, this is not the case when displayed on a Google Map.</p>
<p><iframe frameborder="0" src="http://thydzik.com/thydzik-google-map-old/index.html" width="460" height="345" scrolling="no"></iframe></p>
<p>Have a look at the PHP source code below:</p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	 $color = $_GET['color'];
	 if (!$color) {$color = &quot;ff776b&quot;;} //default google map color
	 $color = str_replace(&quot;#&quot;, &quot;&quot;, $color);
	 $string = $_GET['text'];

	 //some smarts to prevent hotlinking
	 if (!stristr($_SERVER['HTTP_REFERER'], &quot;thydzik.com&quot;)) {
		$string = chr(169);
	 }
	 $font = 'arial';

	 //unfortunately we still must do some offsetting
	 switch (ord(substr($string,0,1))) {
		 case 49: //1
			$offset = -2;
			break;
		 case 55: //7
			$offset = -1;
			break;
		 case 65: //A
			$offset = 1;
			break;
		 case 74: //J
			$offset = -1;
			break;
		 case 84: //T
			$offset = 1;
			break;
		 case 99: //c
			$offset = -1;
			break;
		 case 106: //j
			$offset = 1;
			break;
	 }
	 if (strlen($string) == 1) {
		$fontsize = 10.5;
	 } else if (strlen($string) == 2) {
		$fontsize = 9;
	 } else {
		$fontsize = 10.5;
		$offset = 0; //reset offset
		$string = chr(149);
	 }

	 $bbox = imagettfbbox($fontsize, 0, $font, $string);
	 $width = $bbox[2] - $bbox[0] + 1;
	 $height = $bbox[1] - $bbox[7] + 1;

	 $image_name = &quot;http://chart.apis.google.com/chart?cht=mm&amp;chs=20x34&amp;chco=$color,$color,000000&amp;ext=.png&quot;;
	 $im = imagecreatefrompng($image_name);
	 imageAlphaBlending($im, true);
	 imageSaveAlpha($im, true);
	 $black = imagecolorallocate($im, 0, 0, 0);

	 imagettftext($im, $fontsize, 0, 11 - $width/2 + $offset, 9 + $height/2, $black, $font, $string);

	 header(&quot;Content-type: image/png&quot;);
	 imagepng($im);
	 imagedestroy($im);
?&gt;
</pre>
<p><strong>EDIT: 27th January 2010</strong></p>
<p>I have experienced some users with errors produced by the <em>imagecreatefrompng</em>, either due to versions &lt;4.3.0 disabling remote file access or <em>allow_url_fopen</em> being disabled.</p>
<p>A greater supported alternative is to use curl to fetch the Google marker. Replace the above with the below modification;</p>
<pre class="brush: php; title: ; notranslate">
	$image_name = &quot;http://chart.apis.google.com/chart?cht=mm&amp;chs=20x34&amp;chco=$color,$color,000000&amp;ext=.png&quot;;

	$ch = curl_init();
	curl_setopt ($ch, CURLOPT_URL, $image_name);
	curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, 0);

	// Getting binary data
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1);

	$image_string = curl_exec($ch);
	curl_close($ch);

	$im = imagecreatefromstring ($image_string);
</pre>
<p><strong>EDIT: 30th November 2011</strong></p>
<p>Hosting of these dynamic markers, linked on <a href="http://code.google.com/p/google-maps-icons/wiki/NumericIcons#Symbol_You_Want_on_Color_You_Want" title="Numeric Icons" target="_blank">NumericIcons</a> is using all my allocated hosting server resources. I have modified the script to redirect to Google&#8217;s dynamic markers (yes, Google has the equivalent) hopefully that will take some of the load off, and I won&#8217;t need to remove it totally.</p>
<p>They look slightly different to mine;<br />
<a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=A" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=Z" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=1" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=10" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=PQ" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=69" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=%BE" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=O" alt="O" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=$" alt="$" /></a></p>
<p><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?color=fdabff" alt="Default" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=A&amp;color=c89bff" alt="A" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=Z&amp;color=01bf00" alt="Z" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=1&amp;color=97ec7d" alt="1" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=10&amp;color=6b98ff" alt="10" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=PQ&amp;color=bce3ff" alt="PQ" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=69&amp;color=ffed5c" alt="69" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=%BE&amp;color=cb9d7c" alt="%BE" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=O&amp;color=fd8d08" alt="O" /></a><a><img src="http://thydzik.com/thydzikGoogleMap/markerlink.php?text=$&amp;color=ffffff" alt="$" /></a></p>
<pre class="brush: php; title: ; notranslate">
	if (!$color = $_GET['color']) {
		$color = &quot;ff776b&quot;; //default google map color
	}
	$color = str_replace(&quot;#&quot;, &quot;&quot;, $color);

	if (!$text = $_GET['text']) {
		$text = &quot;%e2%bc%80&quot;; //default google map icon
	}

	header(&quot;Location: http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld={$text}|{$color}|000000&amp;.png&quot;);
</pre>
<p><strong>EDIT: 6 December 2011</strong><br />
I now have implemented an Apache Mod_Rewrite solution, which will take all load off the php processing, existing users should see no difference.</p>
<pre class="brush: plain; title: ; notranslate">
RewriteCond %{QUERY_STRING} ^text=([^&amp;]*)$
RewriteRule ^thydzikGoogleMap/markerlink\.php$ http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld=%1|ff776b|000000&amp;.png? [R,L]

RewriteCond %{QUERY_STRING} ^color=([^&amp;]*)$
RewriteRule ^thydzikGoogleMap/markerlink\.php$ http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld=â¼€|%1|000000&amp;.png? [R,L]

RewriteCond %{QUERY_STRING} ^text=(.*)\&amp;color=(.*)$
RewriteRule ^thydzikGoogleMap/markerlink\.php$ http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld=%1|%2|000000&amp;.png? [R,L]

RewriteCond %{QUERY_STRING} ^color=(.*)\&amp;text=(.*)$
RewriteRule ^thydzikGoogleMap/markerlink\.php$ http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld=%2|%1|000000&amp;.png? [R,L]

RewriteCond %{QUERY_STRING} =&quot;&quot;
RewriteRule ^thydzikGoogleMap/markerlink\.php$ http://chart.googleapis.com/chart?chst=d_map_pin_letter&amp;chld=â¼€|ff776b|000000&amp;.png? [R,L]
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/dynamic-google-maps-markersicons-with-php/' addthis:title='Dynamic Google Maps markers/icons with PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/dynamic-google-maps-markersicons-with-php/feed/</wfw:commentRss>
		<slash:comments>63</slash:comments>
		</item>
		<item>
		<title>RSS feed aggregator/combiner in PHP</title>
		<link>http://thydzik.com/rss-feed-aggregatorcombiner-in-php/</link>
		<comments>http://thydzik.com/rss-feed-aggregatorcombiner-in-php/#comments</comments>
		<pubDate>Tue, 29 Jan 2008 04:43:18 +0000</pubDate>
		<dc:creator>thydzik</dc:creator>
				<category><![CDATA[Random]]></category>
		<category><![CDATA[aggregator]]></category>
		<category><![CDATA[combiner]]></category>
		<category><![CDATA[feed]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[RSS]]></category>
		<category><![CDATA[RSS feed]]></category>
		<category><![CDATA[title]]></category>

		<guid isPermaLink="false">http://blog.thydzik.com/rss-feed-aggregatorcombiner-in-php/</guid>
		<description><![CDATA[Having also a second blog, I needed a way to combine the RSS feeds into one, hence, the following code was written (well, modified from this code). The code uses MagpieRSS to read and FeedCreator to write. Thanks to Scott Hurring for code to grab the RSS feed title. The code has been tested with [...]<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/rss-feed-aggregatorcombiner-in-php/' addthis:title='RSS feed aggregator/combiner in PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>Having also a <a title="Sonya and Travis" href="http://sonyaandtravis.com" target="_blank">second blog</a>, I needed a way to combine the RSS feeds into one, hence, the following code was written (well, modified from <a title="http://theos.in/technology/howto-combine-two-wordpress-rss-feed/" href="http://theos.in/technology/howto-combine-two-wordpress-rss-feed/" target="_blank">this code</a>).</p>
<p>The code uses <a title="MagpieRSS provides an XML-based (expat) RSS parser in PHP" href="http://magpierss.sourceforge.net/" target="_blank">MagpieRSS</a> to read and <a title="Create RSS feeds from within PHP" href="http://feedcreator.org/" target="_blank">FeedCreator</a> to write. Thanks to <a title="URL Title Lookup" href="http://www.hurring.com/scott/code/php/url_title/" target="_blank">Scott Hurring</a> for code to grab the RSS feed title.</p>
<p>The code has been tested with my 2 WordPress blogs (<a title="Example combined feeds" href="http://thydzik.com/combinedfeed/" target="_blank">view example combined RSS feed</a>). To install, extract and upload the <em>feed</em> directory and modify the settings in <em>index.php</em>.</p>
<p><a title="Download thydzik RSS feed aggregator.zip" href="http://thydzik.com/combinedfeed/thydzik-rss-feed-aggregator.zip" target="_blank">Download all files and folders</a></p>
<p><strong>Update: 1 April 2009, improved code speed up the slow response of the url_grab_title function.</strong></p>
<p>Update: 3 March 2010, I have further improved the code and made it easier to intergrate into another site.<br />
<a title="RSS feed aggregator/combiner in PHP v2" href="http://thydzik.com/rss-feed-aggregatorcombiner-in-php-v2/" target="_blank">Refer to this post.</a></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php
	$TMP_ROOT = &quot;tmp/&quot;;
	$DOMAIN_NAME = &quot;http://thydzik.com/&quot;;
	$SITE_TITLE = &quot;thydzik&quot;;
	$SITE_DESRIPTION = &quot;thydzik's blog feeds&quot;;
	$SITE_AUTHOR = &quot;thydzik&quot;;
	$RSS_DIR = &quot;../&quot;;

	$array = array(
		&quot;http://blog.thydzik.com/feed/&quot;,
		&quot;http://sonyaandtravis.com/feed/&quot;
	);
	$num = 10;
	$showfullfeed = FALSE;

	define('MAGPIE_DIR', $RSS_DIR.'feed/');
	define('MAGPIE_CACHE_DIR','/'.$TMP_ROOT.'rsscache');

	/* include required files */
	@require_once(MAGPIE_DIR.'rss_fetch.inc');
	@include(MAGPIE_DIR.'feedcreator.class.php');

	/* Set RSS properties */
	$rss = new UniversalFeedCreator();
	$rss-&gt;useCached();
	$rss-&gt;title = $SITE_TITLE;
	$rss-&gt;description = $SITE_DESRIPTION;
	$rss-&gt;link = $DOMAIN_NAME;
	$rss-&gt;syndicationURL = $DOMAIN_NAME.&quot;feed/index.php&quot;;

	$i_temp = 0; //temp i variable
	$j_temp = 0; //temp j variable
	$total_temp = 0; //temp total number of posts in all rss feeds

	$array_count = count($array); //number of rss feeds

	/* code to determine which post to display */
	for ($i = 0; $i &lt; $array_count; $i++) {
		$rss1 = fetch_rss($array[$i]);
		if ($rss1) {
			$array_temp[$i]['page_title'] = url_grab_title($array[$i]);
			$items = array_slice($rss1-&gt;items, 0);
			$array_temp[$i]['rss_data'] = $items;
			$total_temp += count($items);
			$array_temp[$i]['rss_pointer'] = 0;
			preg_match('@^(?:http://)?([^/]+)@i', $array[$i], $matches);
			$array_temp[$i]['site_url'] = $matches[0];
		}
	}
	while ($total_temp &lt;&gt; 0 &amp;&amp; $num &gt; 0){// loop while there are remaining posts to process
		$date_timestamp_temp = 0; //initialise to 0
		for ($i = 0; $i &lt; $array_count; $i++) {
			$date_timestamp_temp = max($date_timestamp_temp, $array_temp[$i]['rss_data'][$array_temp[$i]['rss_pointer']]['date_timestamp']); //determine latest post from rss feeds
			if ($date_timestamp_temp == $array_temp[$i]['rss_data'][$array_temp[$i]['rss_pointer']]['date_timestamp']) { //latest post is found so save where it came from
				$i_temp = $i;
				$j_temp = $array_temp[$i]['rss_pointer'];
			}
		}
		$total_temp --; //decrement total remaining posts to process
		$num --; //decrement number of posts to display
		$array_temp[$i_temp]['rss_pointer'] ++; //increment post index of used post rss

		/* code to display post */
		$item = $array_temp[$i_temp]['rss_data'][$j_temp];
		$href = $item['link'];
		$title = $item['title'];
		if (!$showfullfeed) {
			$desc = $item['description'];
		}else{
			$desc =  $item['content']['encoded'];
		}
		$desc .=  '
Copyright &amp;copy; &lt;a href=&quot;'.$array_temp[$i_temp]['site_url'].'&quot;&gt;'.$array_temp[$i_temp]['page_title'].'&lt;/a&gt;.  All Rights Reserved.
';
		$pdate = $item['pubdate'];
		$item = new FeedItem();
		$item-&gt;title = $title;
		$item-&gt;link = $href;
		$item-&gt;description = $desc;
		$item-&gt;date = $pdate;
		$item-&gt;source = $DOMAIN_NAME;
		$item-&gt;author = $SITE_AUTHOR;
		$rss-&gt;addItem($item);
	}

	function url_grab_title($rss_url) {
		$contents = file_get_contents($rss_url, TRUE, NULL, 0, 3072);
		$contents = preg_replace(&quot;/(\n|\r)/&quot;, '', $contents);
		preg_match('/&lt;title&gt;(.*?)&lt;\/title&gt;/i', $contents, $matches);
		return $matches[1];
	}

	// get your news items from other feed and display back
	$rss-&gt;saveFeed(&quot;RSS2.0&quot;, '/'.$TMP_ROOT.&quot;rsscache/feed.xml&quot;);
?&gt;
</pre>
<div class="addthis_toolbox addthis_default_style addthis_" addthis:url='http://thydzik.com/rss-feed-aggregatorcombiner-in-php/' addthis:title='RSS feed aggregator/combiner in PHP ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://thydzik.com/rss-feed-aggregatorcombiner-in-php/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced
Object Caching 1427/1434 objects using disk: basic
Content Delivery Network via t01.thydzik.com

Served from: thydzik.com @ 2012-05-23 09:12:41 -->
