<?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>Alex's  Rocket &#187; PHP</title>
	<atom:link href="http://klalex.com/category/php/feed/" rel="self" type="application/rss+xml" />
	<link>http://klalex.com</link>
	<description>Developing web applications, startups, technologies</description>
	<lastBuildDate>Tue, 21 Jun 2011 13:45:30 +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>OpenInviter and UTF8 encoding</title>
		<link>http://klalex.com/2011/01/openinviter-and-russian-names/</link>
		<comments>http://klalex.com/2011/01/openinviter-and-russian-names/#comments</comments>
		<pubDate>Mon, 17 Jan 2011 20:29:17 +0000</pubDate>
		<dc:creator>klalex</dc:creator>
				<category><![CDATA[Open Source]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[import contacts]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[openinviter]]></category>
		<category><![CDATA[russian]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://klalex.com/?p=97</guid>
		<description><![CDATA[If you need to import contacts from other services there is quite good cheap solution for PHP &#8211; open source library www.openinviter.net. It supports a huge amount of services and that&#8217;s awesome. There is nice auto-installer and documentation. Here I just want to discuss an issue that you can experience &#8211; incorrect encoding of russian [...]]]></description>
			<content:encoded><![CDATA[<p>If you need to import contacts from other services there is quite good cheap solution for PHP &#8211; open source library <a href="http://www.openinviter.net" target="_blank">www.openinviter.net</a>. It supports a huge amount of services and that&#8217;s awesome.</p>
<p>There is nice auto-installer and documentation. Here I just want to discuss an issue that you can experience &#8211; incorrect encoding of russian contact names.</p>
<p>To solve it replace in OpenInviter base class the following line:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$name</span><span class="sy0">=</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;first_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;first_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;middle_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;middle_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;last_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;last_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;nickname&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;nickname&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>with</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="re0">$name</span><span class="sy0">=</span><a href="http://www.php.net/utf8_decode"><span class="kw3">utf8_decode</span></a><span class="br0">&#40;</span><a href="http://www.php.net/trim"><span class="kw3">trim</span></a><span class="br0">&#40;</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;first_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;first_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;middle_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;middle_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;last_name&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;last_name&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="sy0">.</span><span class="st_h">&#8216; &#8216;</span><span class="sy0">.</span><span class="br0">&#40;</span><span class="sy0">!</span><a href="http://www.php.net/empty"><span class="kw3">empty</span></a><span class="br0">&#40;</span><span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;nickname&#8217;</span><span class="br0">&#93;</span><span class="br0">&#41;</span>?<span class="re0">$arrayImport</span><span class="br0">&#91;</span><span class="st_h">&#8216;nickname&#8217;</span><span class="br0">&#93;</span><span class="sy0">:</span><span class="kw4">false</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://klalex.com/2011/01/openinviter-and-russian-names/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Using arrays in form element names</title>
		<link>http://klalex.com/2009/07/using-arrays-in-form-element-names/</link>
		<comments>http://klalex.com/2009/07/using-arrays-in-form-element-names/#comments</comments>
		<pubDate>Mon, 27 Jul 2009 13:08:35 +0000</pubDate>
		<dc:creator>klalex</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[form elements]]></category>

		<guid isPermaLink="false">http://klalex.com/?p=68</guid>
		<description><![CDATA[Sometimes there is variable number of similar elements on a form. For example, phone numbers. To iterate all filled values on the server it will be nice to use arrays. And form element naming allow it: &#60;form method=&#34;post&#34;&#62; &#60;input type=&#34;text&#34; name=&#34;phone[0]&#34; /&#62; &#60;input type=&#34;text&#34; name=&#34;phone[1]&#34; /&#62; &#8230; &#60;/form&#62; Using PHP it&#8217;s easy to iterate through [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes there is variable number of similar elements on a form. For example, phone numbers. To iterate all filled values on the server it will be nice to use arrays. And form element naming allow it:</p>
<div class="codesnip-container" >
<div class="html4strict codesnip" style="font-family:monospace;"><span class="sc2">&lt;<a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a> <span class="kw3">method</span><span class="sy0">=</span><span class="st0">&quot;post&quot;</span>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;phone[0]&quot;</span> <span class="sy0">/</span>&gt;</span><br />
<span class="sc2">&lt;<a href="http://december.com/html/4/element/input.html"><span class="kw2">input</span></a> <span class="kw3">type</span><span class="sy0">=</span><span class="st0">&quot;text&quot;</span> <span class="kw3">name</span><span class="sy0">=</span><span class="st0">&quot;phone[1]&quot;</span> <span class="sy0">/</span>&gt;</span><br />
&#8230;<br />
<span class="sc2">&lt;<span class="sy0">/</span><a href="http://december.com/html/4/element/form.html"><span class="kw2">form</span></a>&gt;</span></div>
</div>
<p>Using PHP it&#8217;s easy to iterate through those values now:</p>
<div class="codesnip-container" >
<div class="php codesnip" style="font-family:monospace;"><span class="kw1">foreach</span> <span class="br0">&#40;</span><span class="re0">$_POST</span><span class="br0">&#91;</span><span class="st_h">&#8216;phone&#8217;</span><span class="br0">&#93;</span> <span class="kw1">as</span> phone<span class="br0">&#41;</span> <span class="br0">&#123;</span><br />
<span class="co1">// do something with phone, save in the database</span><br />
<span class="br0">&#125;</span></div>
</div>
<p>But how to access those values with JavaScript? In case we need to validate required fields, for example. It&#8217;s easy to suppose that document.forms[0].phone[0].value returns value. Actually no. In this case we need to use document.forms[0].elements array and access by key:</p>
<div class="codesnip-container" >
<div class="javascript codesnip" style="font-family:monospace;"><span class="kw3">alert</span><span class="br0">&#40;</span>document.<span class="me1">forms</span><span class="br0">&#91;</span><span class="nu0">0</span><span class="br0">&#93;</span>.<span class="me1">elements</span><span class="br0">&#91;</span><span class="st0">&quot;phone[0]&quot;</span><span class="br0">&#93;</span>.<span class="me1">value</span><span class="br0">&#41;</span><span class="sy0">;</span></div>
</div>
<p>Using arrays in form element naming allows us to control the variable number of form elements. For example, we can add link &#8220;Add another phone&#8221; and when user clicks on it add new &lt;input type=&#8221;text&#8221; name=&#8221;phone[2]&#8221; /&gt; field. And we do not need to change anything in PHP code because it will iterate all values that we have passed to the server.</p>
]]></content:encoded>
			<wfw:commentRss>http://klalex.com/2009/07/using-arrays-in-form-element-names/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Installing GD on Mac OS Leopard</title>
		<link>http://klalex.com/2008/10/installing-gd-on-mac-os-leopard/</link>
		<comments>http://klalex.com/2008/10/installing-gd-on-mac-os-leopard/#comments</comments>
		<pubDate>Tue, 28 Oct 2008 11:08:53 +0000</pubDate>
		<dc:creator>klalex</dc:creator>
				<category><![CDATA[Mac OS]]></category>
		<category><![CDATA[PHP]]></category>

		<guid isPermaLink="false">http://klalex.com/?p=19</guid>
		<description><![CDATA[Found a great article how to do this &#8211; Install GD for PHP on Mac OS X 10.5 Leopard. Thanks, Chris!]]></description>
			<content:encoded><![CDATA[<p>Found a great article how to do this &#8211; <a href="http://www.gigoblog.com/2008/10/08/install-gd-for-php-on-mac-os-x-105-leopard/" target="_blank">Install GD for PHP on Mac OS X 10.5 Leopard</a>. Thanks, Chris!</p>
]]></content:encoded>
			<wfw:commentRss>http://klalex.com/2008/10/installing-gd-on-mac-os-leopard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

