<?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>Alejandro Moraga</title>
	<atom:link href="http://www.alejandromoraga.com/feed" rel="self" type="application/rss+xml" />
	<link>http://www.alejandromoraga.com</link>
	<description>the world is who develops</description>
	<lastBuildDate>Fri, 03 Dec 2010 20:49:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.2</generator>
		<item>
		<title>Placeholder plugin for jQuery</title>
		<link>http://www.alejandromoraga.com/placeholder-plugin-for-jquery</link>
		<comments>http://www.alejandromoraga.com/placeholder-plugin-for-jquery#comments</comments>
		<pubDate>Fri, 03 Dec 2010 20:43:34 +0000</pubDate>
		<dc:creator>moraga</dc:creator>
				<category><![CDATA[HTML]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[HTML5]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://www.alejandromoraga.com/?p=7</guid>
		<description><![CDATA[Placeholder its a new attribute of HTML5. Your functionality is add label inside inputs when empty. &#62;input type="text" placeholder="Enter your name here!" /&#62; Some browsers like Firefox in version 3.6 doesn&#8217;t have support for this attribute. The code below is an plugin for jQuery that simulate placeholder. (function($) { $.fn.extend({ placeholder: function() { return this.each(function() [...]]]></description>
			<content:encoded><![CDATA[<p><strong>Placeholder</strong> its a new attribute of HTML5. Your functionality is add label inside inputs when empty.</p>
<pre style="clear:left">&gt;input type="text" placeholder="Enter your name here!" /&gt;</pre>
<p>Some browsers like Firefox in version 3.6 doesn&#8217;t have support for this attribute.</p>
<p>The code below is an plugin for jQuery that simulate placeholder.</p>
<pre>(function($) {
	$.fn.extend({
		placeholder: function() {
			return this.each(function() {
				$('[placeholder]', this)
					.focus(function() {
						if ($(this).val() == $(this).attr('placeholder'))
							$(this).val('').css('color', '#000');
					})
					.blur(function() {
						if (!$(this).val() || $(this).val() == $(this).attr('placeholder'))
							$(this).val(function() { return $(this).attr('placeholder') }).css('color', '#ccc');
					})
					.filter(':not([value])').val(function() { return $(this).attr('placeholder') }).css('color', '#ccc')
					.parents('form')
						.bind('submit', function() {
							$('[placeholder]', this).val(function() { return $(this).val() != $(this).attr('placeholder') ? $(this).val() : '' });
						});
			});
		}
	});
})(jQuery);</pre>
<p>To use is very simple. Put the attribute into HTML tags normally and in the parent of all elements that you use execute the code:</p>
<pre>$('parent').placehoder();</pre>
<p>Example:</p>
<pre>$('form').placeholder();</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.alejandromoraga.com/placeholder-plugin-for-jquery/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>From array to URL</title>
		<link>http://www.alejandromoraga.com/from-array-to-url</link>
		<comments>http://www.alejandromoraga.com/from-array-to-url#comments</comments>
		<pubDate>Fri, 03 Dec 2010 08:27:27 +0000</pubDate>
		<dc:creator>moraga</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://www.alejandromoraga.com./?p=1</guid>
		<description><![CDATA[$_GET is an associative array of variables passed in URL. Example: http://exemplo.com?name=Alejandro&#38;age=23&#38;gender=male That URL have many variables: print_r($_GET); array ( name =&#62; Alejandro, age =&#62; 23, gender =&#62; male ) We can access the variable values using indexes: echo $_GET['age']; // show 23 echo $_GET['gender']; // show male From array to URL parameters Doesn&#8217;t exists [...]]]></description>
			<content:encoded><![CDATA[<p><code>$_GET</code> is an associative array of variables passed in URL.</p>
<p>Example:</p>
<pre>http://exemplo.com?name=Alejandro&amp;age=23&amp;gender=male</pre>
<p>That URL have many variables:</p>
<pre>print_r($_GET);

array
(
	name =&gt; Alejandro,
	age =&gt; 23,
	gender =&gt; male
)</pre>
<p>We can access the variable values using indexes:</p>
<pre>echo $_GET['age']; // show 23
echo $_GET['gender']; // show male</pre>
<h1>From array to URL parameters</h1>
<p>Doesn&#8217;t exists an native PHP function to convert array in URL parameters. So lets make our function:</p>
<pre>function arrtourl($arr, $entity=true, $prefix='') {
	$params = array();
	foreach ($arr as $k =&gt; $v)
		if ($v)
			$params[] = is_array($v) ? arrtourl($v, $entity, $prefix ? $prefix.'['.$k.']' : $k) : sprintf($prefix ? $prefix.'[%s]' : '%s', urlencode($k)).'='.urlencode($v);
	return implode($entity ? '&amp;amp;' : '&amp;', $params);
}</pre>
<h3>Parameters</h3>
<dl>
<dt><code>$arr</code></dt>
<dd>is the array to be converted.</dd>
<dt><code>$entity</code></dt>
<dd>is a boolean who defines if the parameters will be joined using &amp;amp; or &amp;. The default value is true because in most cases the URL parameters create from here will be used in HTML content.</dd>
<dt><code>$prefix</code></dt>
<dd>this parameters are used in recursions when <code>$arr</code> is an matrix.</dd>
</dl>
<h3>Examples</h3>
<p>Simple:</p>
<pre>$arr = array(
	'id' =&gt; 968,
	'cat' =&gt; 'php'
);

echo arrtourl($arr);

&gt;&gt; id=968&amp;amp;cat=php</pre>
<p>Matrix:</p>
<pre>$mat = array(
	'test' =&gt; array(
		'id' =&gt; 968,
		'cat' =&gt; php
	),
	'status' =&gt; 1,
	'seq' =&gt; array(
		1,
		2,
		3
	)
);

echo arrtourl($mat);

&gt;&gt; test[id]=968&amp;amp;test[cat]=php&amp;amp;status=1&amp;amp;seq[0]=1&amp;amp;seq[1]=2&amp;amp;seq[2]=3</pre>
<p>Many dimensions:</p>
<pre>$arr = array(
	'val' =&gt; array(
		array(
			array(
				'test'
			)
		)
	)
);

echo arrtourl($arr);

&gt;&gt; val[0][0][0]=test</pre>
<p>Just &amp;:</p>
<pre>$arr = array(
	'id' =&gt; 968,
	'cat' =&gt; 'php',
);

// id=968&amp;cat=php
$url = arrtourl($arr, false);

header('Location: mypage?'.$url);</pre>
<p>Adding prefix:</p>
<pre>$arr = array(
	'id' =&gt; 968,
	'cat' =&gt; 'php'
);

echo arrtourl($arr, false, 'post');

&gt;&gt; post[id]=968&amp;post[cat]=php</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.alejandromoraga.com/from-array-to-url/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

