<?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>Cristián Pérez</title>
	<atom:link href="http://www.cristianperez.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.cristianperez.com</link>
	<description>Experimentando la vida</description>
	<lastBuildDate>Tue, 27 Jul 2010 22:59:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<item>
		<title>Generador de ID continuas al estilo URL corta</title>
		<link>http://www.cristianperez.com/2010/03/23/generador-de-id-continuas-al-estilo-url-corta/</link>
		<comments>http://www.cristianperez.com/2010/03/23/generador-de-id-continuas-al-estilo-url-corta/#comments</comments>
		<pubDate>Tue, 23 Mar 2010 03:21:11 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[Recursos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=293</guid>
		<description><![CDATA[Bueno&#8230;. si&#8230; es bueno para matar al Alzheimer Bajo la duda de un amigo acerca de como generar numeros de ID cortos para utilizar en un servicio acortador de url&#8217;s se me ocurrio utilizar letras mayusculas y minusculas para aumentar la cantidad de posibles valores en una posicion de la cadena, ya que los numeros]]></description>
			<content:encoded><![CDATA[<p>Bueno&#8230;. si&#8230; es bueno para matar al <a href="http://es.wikipedia.org/wiki/Enfermedad_de_Alzheimer">Alzheimer</a></p>
<p>Bajo la duda de un amigo acerca de como generar numeros de ID cortos para utilizar en un servicio acortador de url&#8217;s se me ocurrio utilizar letras mayusculas y minusculas para aumentar la cantidad de posibles valores en una posicion de la cadena, ya que los numeros solo permitian 10 posibilidades (0-9) y la cadena se alargaria rapidamente.<span id="more-293"></span><br />
De esta manera puedo generar cadenas al estilo &#8220;a1D2&#8243;, y producir su valor consecutivo, que quedaria asi &#8220;a1D3&#8243;, asi hasta llegar al &#8220;a1D9&#8243; y luego comenzar con &#8220;a1DA&#8221;, asi hasta terminar las mayusculas, y minusculas. Una vez sucedido esto, el movimiento es similar al de un cuenta kilometros. y el valor quedaria asi &#8220;a1F0&#8243; y podriamos seguir!..</p>
<p>Ahora bien, la funcion puede generar el siguiente id, partiendo desde cualquier anterior!..<br />
Por ejemplo, si le ingresaramos el ID &#8220;0&#8243; nos devolveria 1 y si ingresaramos el id &#8220;0000&#8243; nos devolveria 0001, tambien si pusieramos &#8220;ABCD&#8221; nos devolveria &#8220;ABCE&#8221;.</p>
<p>La declaración de la funcion es la siguiente.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Genera la cadena siguiente a una cadena de caracteres alphanumericos no simbolicos ingresada
 * 
 * @author Cristián Pérez
 * @param string $current
 * @return string
 * 
 */</span>
<span style="color: #009900; font-weight: bold;">function</span> getNextKey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$chars</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
	<span style="color: #009900;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">0</span><span style="color: #000000;">;</span> <span style="color: #000088;">$i</span> <span style="color: #000000;">&lt;</span> <span style="color: #990000;">strlen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span> <span style="color: #000088;">$i</span><span style="color: #000000;">++</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #990000;">ord</span><span style="color: #009900;">&#40;</span><span style="color: #990000;">substr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span><span style="color: #000000;">,</span> <span style="color: #000088;">$i</span><span style="color: #000000;">,</span> <span style="color: #ff0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000088;">$ci</span> <span style="color: #000000;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#41;</span> <span style="color: #000000;">-</span> <span style="color: #ff0000;">1</span><span style="color: #000000;">;</span>
&nbsp;
	<span style="color: #009900;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$ci</span><span style="color: #000000;">;;</span><span style="color: #000088;">$i</span><span style="color: #000000;">--</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&gt;=</span> <span style="color: #ff0000;">48</span> <span style="color: #000000;">&amp;&amp;</span> <span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&lt;</span> <span style="color: #ff0000;">57</span><span style="color: #009900;">&#41;</span> <span style="color: #000000;">||</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&gt;=</span> <span style="color: #ff0000;">65</span> <span style="color: #000000;">&amp;&amp;</span> <span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&lt;</span> <span style="color: #ff0000;">90</span><span style="color: #009900;">&#41;</span> xor <span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&gt;=</span> <span style="color: #ff0000;">97</span> <span style="color: #000000;">&amp;&amp;</span> <span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">&lt;</span> <span style="color: #ff0000;">122</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000000;">++</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #000000;">;</span>
			<span style="color: #009900;">break</span><span style="color: #000000;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">==</span> <span style="color: #ff0000;">57</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">65</span><span style="color: #000000;">;</span>
			<span style="color: #009900;">break</span><span style="color: #000000;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">elseif</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">==</span> <span style="color: #ff0000;">90</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">97</span><span style="color: #000000;">;</span>
			<span style="color: #009900;">break</span><span style="color: #000000;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
		<span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span> <span style="color: #000000;">==</span> <span style="color: #ff0000;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">==</span> <span style="color: #ff0000;">122</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #009900;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span> <span style="color: #009900;">as</span> <span style="color: #000000;">&amp;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span>
				<span style="color: #009900;">&#123;</span>
					<span style="color: #000088;">$char</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">48</span><span style="color: #000000;">;</span>
				<span style="color: #009900;">&#125;</span>
&nbsp;
				<span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">48</span><span style="color: #000000;">;</span>
			<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">break</span><span style="color: #000000;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">else</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000088;">$chars</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">48</span><span style="color: #000000;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$chars</span> <span style="color: #009900;">as</span> <span style="color: #000000;">&amp;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000088;">$char</span> <span style="color: #000000;">=</span> <span style="color: #990000;">chr</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">return</span> <span style="color: #990000;">implode</span><span style="color: #009900;">&#40;</span><span style="color: #C30;">''</span><span style="color: #000000;">,</span> <span style="color: #000088;">$chars</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Un ejemplo practico para que entiendan como funciona es el siguiente, el cual pueden copiar y pegar en un archivo nuevo para que lo prueben.
</pre>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$form</span> <span style="color: #000000;">=</span> <span style="color: #C30;">'&lt;form action=&quot;&quot; method=&quot;post&quot;&gt;'</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$form</span> <span style="color: #000000;">.=</span> <span style="color: #C30;">'&lt;input type=&quot;text&quot; name=&quot;currentID&quot; value=&quot;%s&quot; /&gt;'</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$form</span> <span style="color: #000000;">.=</span> <span style="color: #C30;">'&lt;input type=&quot;submit&quot; value=&quot;Siguiente ID&quot; /&gt;'</span><span style="color: #000000;">;</span>
<span style="color: #000088;">$form</span> <span style="color: #000000;">.=</span> <span style="color: #C30;">'&lt;/form&gt;'</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #009900;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #000000;">,</span> getNextKey<span style="color: #009900;">&#40;</span><span style="color: #000088;">$_POST</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'currentID'</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">else</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #990000;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$form</span><span style="color: #000000;">,</span> <span style="color: #C30;">'0'</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Bugs, preguntas, sugerencias, lo que sea es aceptado!.</p>
<p>Espero que les sirva!<br />
Saludos!!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2010/03/23/generador-de-id-continuas-al-estilo-url-corta/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Conceptos (P1): Tipos de datos</title>
		<link>http://www.cristianperez.com/2010/03/12/conceptos-p1-tipos-de-datos/</link>
		<comments>http://www.cristianperez.com/2010/03/12/conceptos-p1-tipos-de-datos/#comments</comments>
		<pubDate>Fri, 12 Mar 2010 03:00:43 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[Conceptos sobre Programación]]></category>
		<category><![CDATA[conceptos]]></category>
		<category><![CDATA[programacion]]></category>
		<category><![CDATA[tipos de datos]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=257</guid>
		<description><![CDATA[Bueno, no sabia que escribir, así que me decidí a empezar a escribir algunas guías que ayuden a entender cuestiones básicas sobre programación, mi idea es hacerlo de la forma mas neutra posible con respecto al lenguaje de programación que uno elija utilizar. Me parecio importante empezar hablando sobre los tipos de datos, para así]]></description>
			<content:encoded><![CDATA[<p>Bueno, no sabia que escribir, así que me decidí a empezar a escribir algunas guías que ayuden a entender cuestiones básicas sobre programación, mi idea es hacerlo de la forma mas neutra posible con respecto al lenguaje de programación que uno elija utilizar.</p>
<p>Me parecio importante empezar hablando sobre los tipos de datos, para así seguir con otras cuestiones mas profundas luego.</p>
<p>Empecemos.<br />
<span id="more-257"></span><br />
<span style="color: #3366ff;"><strong>¿A que nos referimos cuando decimos tipo de dato?</strong></span><br />
En simples palabras nos referimos a los valores que se van a manejar.<br />
Cuando se esta programando en algún lenguaje de programación (sea cual sea) y se define una variable con un tipo de dato especifico se le esta dando a la computadora de alguna manera información sobre estos valores.</p>
<p><span style="color: #3366ff;"><strong>¿Y ahora, que tipos de datos existen?</strong></span><br />
Los tipos de datos que podemos encontrar dependen en gran parte del lenguaje de programación que utilicemos, aunque muchos lenguajes permiten la creación de nuevos tipos de datos. Este es el caso típico del lenguaje C/C++</p>
<p>Ahora bien, podríamos dividir básicamente a los tipos de datos en dos grandes grupos:</p>
<p><span style="text-decoration: underline;"><strong>Tipos Primitivos</strong></span><br />
En este grupo podemos encontrar a los tipos:</p>
<p><em><strong>Int</strong></em> : Un numero entero cualquiera<br />
<em><strong>Char</strong></em> : Caracter alfanumérico<br />
<em><strong>Float</strong></em> : Numero Real (con o sin coma)<br />
<em><strong>Boolean</strong></em> : Es un tipo de dato logico, cuyos valores pueden ser solamente VERDADERO o FALSO.<br />
En lenguajes de programación donde este tipo de dato no esta definido se hace uso de los enteros 1 y 0 respectivamente.<br />
<em><strong>String</strong></em> : Cadena de caracteres. Es un conjunto de caracteres alfanuméricos.<br />
<em><strong>Puntero</strong></em> : Es un tipo de dato que tiene la capacidad de almacenar la dirección memoria del valor que se le asigne.<br />
Esto significa que no se produce una copia del dato asignado en una nueva dirección de memoria, sino que al interactuar nosotros con la variable definida como puntero, estamos accediendo directamente a la dirección de memoria del dato que le fue asignado</p>
<p>Estos ultimos 3 tipos de datos son considerados primitivos solo en algunos lenguajes.</p>
<p><span style="text-decoration: underline;"><strong>Tipos Compuestos</strong></span></p>
<p><em><strong>String</strong></em> : Cadena de caracteres<br />
<em><strong>Array</strong></em> : También conocido como matriz, es un tipo de dato capas de contener diferentes valores dentro de si mismo.<br />
Podemos imaginarnos un array unidimensional de la siguiente forma:</p>
<table cellpadding="0" cellspacing="0" border="0">
<tr>
<td style="padding: 5px;">0</td>
<td style="padding: 5px;">1</td>
<td style="padding: 5px;">2</td>
<td style="padding: 5px;">3</td>
<td style="padding: 5px;">4</td>
<td style="padding: 5px;">5</td>
</tr>
<tr>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; padding: 5px;">&nbsp;</td>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; padding: 5px;">&nbsp;</td>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; padding: 5px;">&nbsp;</td>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; padding: 5px;">&nbsp;</td>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; padding: 5px;">&nbsp;</td>
<td style="border-top: 1px solid; border-bottom: 1px solid; border-left: 1px solid; border-right: 1px solid; padding: 5px;">&nbsp;</td>
</tr>
</table>
<p>En el ejemplo vemos un array de 6 posiciones en las cuales podemos almacenar datos, con sus respectivas claves (Keys) que van desde el valor 0 hasta el 5<br />
Dentro de cada una de esas posiciones es posible almacenar un valor cualquiera del tipo de dato simple bajo el cual se haya definido el array.</p>
<p><span style="color: #3366ff;"><strong>Algunos ejemplos practicos</strong></span></p>
<p>Definición de una variable de tipo entero en C++</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #993333;">int</span> miVariable <span style="color: #339933;">=</span> <span style="color: #0000dd;">5</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Defino la variable con 5 como valor inicial</span>
&nbsp;
miVariable <span style="color: #339933;">=</span> <span style="color: #0000dd;">6</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Se asigna el valor 6 a la variable anteriormente definida.</span>
&nbsp;
miVariable <span style="color: #339933;">=</span> <span style="color:#800080;">3.5</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">//Esto produciría un error!, ya que el dato que se intenta asignar es de coma flotante</span></pre></div></div>

<p>Ejemplo de tipo String en PHP</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$miVariable</span> <span style="color: #000000;">=</span> <span style="color: #C30;">&quot;Este es un ejemplo de cadena&quot;</span><span style="color: #000000;">;</span>
<span style="color: #666666; font-style: italic;">/* En este caso no hace falta anteponer el tipo de dato al nombre de la variable en su definicion ya que PHP es un lenguaje dinamicamente tipado, lo cual permite que las variables cambien de tipo de datos con solo asignarle un valor de este nuevo */</span>
&nbsp;
<span style="color: #000088;">$miVariable</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">4</span><span style="color: #000000;">;</span> <span style="color: #666666; font-style: italic;">//Se pierde la cadena anteriormente asignada, y es reemplazada por el valor 4, pasando a ser esta variable de tipo Int en lugar de String</span></pre></div></div>

<p>Ejemplo de Array en lenguaje Python</p>

<div class="wp_syntax"><div class="code"><pre class="python" style="font-family:monospace;">miArray = <span style="color: black;">&#91;</span><span style="color: #483d8b;">'Valor'</span>, <span style="color: #ff4500;">4</span>, <span style="color: #483d8b;">'Otro valor'</span>, <span style="color: #008000;">True</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;">#Este array contiene 4 posiciones</span>
&nbsp;
<span style="color: #ff7700;font-weight:bold;">print</span> miArray<span style="color: black;">&#91;</span><span style="color: #ff4500;">2</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;">#Esto imprimiria la cadena &quot;Otro valor&quot;</span>
<span style="color: #ff7700;font-weight:bold;">print</span> miArray<span style="color: black;">&#91;</span><span style="color: #ff4500;">1</span><span style="color: black;">&#93;</span> <span style="color: #808080; font-style: italic;">#Imprimiria el entero 4</span></pre></div></div>

<p>Espero que les haya servido, pronto seguiremos con otras cuestiones teoricas basicas sobre programación</p>
<p>Saludos</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2010/03/12/conceptos-p1-tipos-de-datos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Obtener el verdadero scope de un metodo en un objeto o clase PHP</title>
		<link>http://www.cristianperez.com/2010/02/19/obtener-el-verdadero-scope-de-un-metodo-en-un-objeto-o-clase-php/</link>
		<comments>http://www.cristianperez.com/2010/02/19/obtener-el-verdadero-scope-de-un-metodo-en-un-objeto-o-clase-php/#comments</comments>
		<pubDate>Fri, 19 Feb 2010 20:47:50 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=259</guid>
		<description><![CDATA[La siguiente funcion soluciona el problema que tienen las funciones nativas de PHP para brindar informacion sobre metodos de Objetos o Clases. La misma permite conocer si un metodo existe y a la vez, si es un metodo privado o publico. Los valores que devuelve son: 0 Si el metodo no existe 1 Si el]]></description>
			<content:encoded><![CDATA[<p>La siguiente funcion soluciona el problema que tienen las funciones nativas de PHP para brindar informacion sobre metodos de Objetos o Clases.</p>
<p>La misma permite conocer si un metodo existe y a la vez, si es un metodo privado o publico.<br />
<span id="more-259"></span><br />
Los valores que devuelve son:<br />
0 Si el metodo no existe<br />
1 Si el metodo existe pero es privado<br />
2 Si el metodo existe y es publico</p>
<p>El codigo es el siguiente y espero que les sirva</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * @name Get Method Scope
 * @param mixed $class ClassName u Object
 * @param string $method
 * @return integer
 * 
 * @author Cristián Pérez
 * 
 * $class puede ser un objeto tambien
 * La funcion devuelve
 * 0: Si el metodo o la clase (u objeto) no existen
 * 1: Si el metodo existe pero es privado
 * 2: Si el metodo existe y es publico!
 * 
 **/</span>
<span style="color: #009900; font-weight: bold;">function</span> method_scope <span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #000000;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #000088;">$all</span> <span style="color: #000000;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #990000;">get_class_methods</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
	<span style="color: #009900;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000000;">!</span> <span style="color: #990000;">in_array</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$method</span><span style="color: #000000;">,</span> <span style="color: #000088;">$all</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #009900;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">method_exists</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$class</span><span style="color: #000000;">,</span> <span style="color: #000088;">$method</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">return</span> <span style="color: #ff0000;">1</span><span style="color: #000000;">;</span> <span style="color: #666666; font-style: italic;">//Private</span>
&nbsp;
		<span style="color: #009900;">return</span> <span style="color: #ff0000;">0</span><span style="color: #000000;">;</span> <span style="color: #666666; font-style: italic;">//It doesn't exists</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">return</span> <span style="color: #ff0000;">2</span><span style="color: #000000;">;</span> <span style="color: #666666; font-style: italic;">//Public</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Ejemplo de Implementacion:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$scope</span> <span style="color: #000000;">=</span> method_scope <span style="color: #009900;">&#40;</span><span style="color: #000088;">$objeto</span><span style="color: #000000;">,</span> <span style="color: #C30;">&quot;miMetodo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #009900;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$scope</span> <span style="color: #000000;">==</span> <span style="color: #ff0000;">2</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">echo</span> <span style="color: #C30;">'El metodo es Publico'</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Saludos</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2010/02/19/obtener-el-verdadero-scope-de-un-metodo-en-un-objeto-o-clase-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Borrar un directorio no vacio con PHP</title>
		<link>http://www.cristianperez.com/2010/01/05/borrar-un-directorio-no-vacio-con-php/</link>
		<comments>http://www.cristianperez.com/2010/01/05/borrar-un-directorio-no-vacio-con-php/#comments</comments>
		<pubDate>Tue, 05 Jan 2010 21:31:54 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[Recursos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=223</guid>
		<description><![CDATA[Muchos habran visto que al querer borrar un directorio que no esta vacio usando la funcion rmdir() nos arroja un error informandonos sobre esto Por eso cree esta funcion que elimina todo el arbol completo de archivos y carpetas dentro de un directorio en particular La definicion es la siguiente: /** * Remove a non]]></description>
			<content:encoded><![CDATA[<p>Muchos habran visto que al querer borrar un directorio que no esta vacio usando la funcion rmdir() nos arroja un error informandonos sobre esto<br />
Por eso cree esta funcion que elimina todo el arbol completo de archivos y carpetas dentro de un directorio en particular<br />
<span id="more-223"></span></p>
<p>La definicion es la siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009933; font-style: italic;">/**
 * Remove a non empty directory
 * @author Cristián Pérez
 * @param string $path Folder Path
 * @return bool
 */</span>
<span style="color: #009900; font-weight: bold;">function</span> removeDirectory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$path</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$path</span> <span style="color: #000000;">=</span> <span style="color: #990000;">rtrim</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">strval</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$path</span> <span style="color: #009900;">&#41;</span><span style="color: #000000;">,</span> <span style="color: #C30;">'/'</span> <span style="color: #009900;">&#41;</span> <span style="color: #000000;">;</span>
&nbsp;
    <span style="color: #000088;">$d</span> <span style="color: #000000;">=</span> <span style="color: #990000;">dir</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$path</span> <span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
    <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000000;">!</span> <span style="color: #000088;">$d</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">return</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #000000;">;</span>
&nbsp;
    <span style="color: #009900;">while</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #000000;">!==</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$current</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$d</span><span style="color: #000000;">-&gt;</span><span style="color: #000000; font-weight: bold;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$current</span> <span style="color: #000000;">===</span> <span style="color: #C30;">'.'</span> <span style="color: #000000;">||</span> <span style="color: #000088;">$current</span> <span style="color: #000000;">===</span> <span style="color: #C30;">'..'</span><span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">continue</span><span style="color: #000000;">;</span>
&nbsp;
        <span style="color: #000088;">$file</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$d</span><span style="color: #000000;">-&gt;</span><span style="color: #000000; font-weight: bold;">path</span> <span style="color: #000000;">.</span> <span style="color: #C30;">'/'</span> <span style="color: #000000;">.</span> <span style="color: #000088;">$current</span><span style="color: #000000;">;</span>
&nbsp;
        <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_dir</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
            removeDirectory<span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
        <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
            <span style="color: #990000;">unlink</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$file</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #990000;">rmdir</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$d</span><span style="color: #000000;">-&gt;</span><span style="color: #000000; font-weight: bold;">path</span> <span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #000088;">$d</span><span style="color: #000000;">-&gt;</span><span style="color: #000000; font-weight: bold;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">return</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #000000;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>La implementacion es la siguiente:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">removeDirectory<span style="color: #009900;">&#40;</span><span style="color: #C30;">&quot;/path/to/dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>Espero que les sirva! Saludos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2010/01/05/borrar-un-directorio-no-vacio-con-php/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Forzar descarga de un archivo</title>
		<link>http://www.cristianperez.com/2009/12/31/forzar-descarga-de-un-archivo/</link>
		<comments>http://www.cristianperez.com/2009/12/31/forzar-descarga-de-un-archivo/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 18:15:24 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[Recursos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=180</guid>
		<description><![CDATA[Muchas veces habran querido permitir la descarga de un archivo con extension &#8220;.php&#8221; por ejemplo de sus sitios sin tener que comprimirlo o un archivo de imagen, evitando que el navegador la muestre La definicion de la funcion es la siguiente function forceDownload&#40; $filePath &#41; &#123; if&#40; is_readable&#40;$filePath&#41; &#41; &#123; header&#40;&#34;Content-type: application/octet-stream&#34;&#41;; header&#40;&#34;Content-Disposition: attachment; filename=\&#34;$filePath\&#34;\n&#34;&#41;;]]></description>
			<content:encoded><![CDATA[<p>Muchas veces habran querido permitir la descarga de un archivo con extension &#8220;.php&#8221; por ejemplo de sus sitios sin tener que comprimirlo o un archivo de imagen, evitando que el navegador la muestre<br />
<span id="more-180"></span></p>
<p>La definicion de la funcion es la siguiente</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900; font-weight: bold;">function</span> forceDownload<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$filePath</span> <span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #990000;">is_readable</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filePath</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #C30;">&quot;Content-type: application/octet-stream&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #990000;">header</span><span style="color: #009900;">&#40;</span><span style="color: #C30;">&quot;Content-Disposition: attachment; filename=<span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #006699; font-weight: bold;">$filePath</span><span style="color: #000099; font-weight: bold;">\&quot;</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #000088;">$fp</span> <span style="color: #000000;">=</span> <span style="color: #990000;">fopen</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$filePath</span><span style="color: #000000;">,</span> <span style="color: #C30;">&quot;r&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #990000;">fpassthru</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$fp</span> <span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #990000;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">else</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">echo</span> <span style="color: #C30;">'Archivo no existente o sin permisos de lectura'</span><span style="color: #000000;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y su utilizacion (por ejemplo) la siguiente</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">forceDownload<span style="color: #009900;">&#40;</span><span style="color: #C30;">&quot;/path/to/file.jpg&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>Saludos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/12/31/forzar-descarga-de-un-archivo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Contar elementos repetidos en un array</title>
		<link>http://www.cristianperez.com/2009/12/31/contar-elementos-repetidos-en-un-array/</link>
		<comments>http://www.cristianperez.com/2009/12/31/contar-elementos-repetidos-en-un-array/#comments</comments>
		<pubDate>Thu, 31 Dec 2009 18:04:58 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[Recursos]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=178</guid>
		<description><![CDATA[Esta funcion devuelve un array con todos los elementos repetidos dentro de un array especifico, y la cantidad de veces que cada elemento aparecio La definicion es la siguiente function repeatedElements&#40;$array&#41; &#160; &#123; $repeated = array&#40;&#41;; &#160; &#160; foreach&#40; &#40;array&#41;$array as $value &#41; &#123; $inArray = false; &#160; foreach&#40; $repeated as $i =&#62; $rItem &#41;]]></description>
			<content:encoded><![CDATA[<p>Esta funcion devuelve un array con todos los elementos repetidos dentro de un array especifico, y la cantidad de veces que cada elemento aparecio<br />
<span id="more-178"></span></p>
<p>La definicion es la siguiente</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #009900; font-weight: bold;">function</span> repeatedElements<span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span>
&nbsp;
<span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$repeated</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
&nbsp;
    <span style="color: #009900;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#41;</span><span style="color: #000088;">$array</span> <span style="color: #009900;">as</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$inArray</span> <span style="color: #000000;">=</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #000000;">;</span>
&nbsp;
        <span style="color: #009900;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$repeated</span> <span style="color: #009900;">as</span> <span style="color: #000088;">$i</span> <span style="color: #000000;">=&gt;</span> <span style="color: #000088;">$rItem</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$rItem</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'value'</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">===</span> <span style="color: #000088;">$value</span> <span style="color: #009900;">&#41;</span>
            <span style="color: #009900;">&#123;</span>
                <span style="color: #000088;">$inArray</span> <span style="color: #000000;">=</span> <span style="color: #009900; font-weight: bold;">true</span><span style="color: #000000;">;</span>
                <span style="color: #000000;">++</span><span style="color: #000088;">$repeated</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'count'</span><span style="color: #009900;">&#93;</span><span style="color: #000000;">;</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #009900; font-weight: bold;">false</span> <span style="color: #000000;">===</span> <span style="color: #000088;">$inArray</span> <span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #000088;">$i</span> <span style="color: #000000;">=</span> <span style="color: #990000;">count</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$repeated</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
            <span style="color: #000088;">$repeated</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
            <span style="color: #000088;">$repeated</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'value'</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #000088;">$value</span><span style="color: #000000;">;</span>
            <span style="color: #000088;">$repeated</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">=</span> <span style="color: #ff0000;">1</span><span style="color: #000000;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
&nbsp;
    <span style="color: #009900;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$repeated</span> <span style="color: #009900;">as</span> <span style="color: #000088;">$i</span> <span style="color: #000000;">=&gt;</span> <span style="color: #000088;">$rItem</span> <span style="color: #009900;">&#41;</span>
    <span style="color: #009900;">&#123;</span>
        <span style="color: #009900;">if</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rItem</span><span style="color: #009900;">&#91;</span><span style="color: #C30;">'count'</span><span style="color: #009900;">&#93;</span> <span style="color: #000000;">===</span> <span style="color: #ff0000;">1</span><span style="color: #009900;">&#41;</span>
        <span style="color: #009900;">&#123;</span>
            <span style="color: #990000;">unset</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$repeated</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
        <span style="color: #009900;">&#125;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$repeated</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
    <span style="color: #009900;">return</span> <span style="color: #000088;">$repeated</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Y la implementacion seria la siguiente por ejemplo</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$arrayParaChequear</span> <span style="color: #000000;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #C30;">&quot;hola&quot;</span><span style="color: #000000;">,</span> <span style="color: #C30;">&quot;chau&quot;</span><span style="color: #000000;">,</span> <span style="color: #C30;">&quot;chau&quot;</span><span style="color: #000000;">,</span> <span style="color: #C30;">&quot;hola&quot;</span><span style="color: #000000;">,</span> <span style="color: #ff0000;">1</span><span style="color: #000000;">,</span> <span style="color: #ff0000;">5</span><span style="color: #000000;">,</span> <span style="color: #ff0000;">3</span><span style="color: #000000;">,</span> <span style="color: #ff0000;">1</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #000088;">$repetidos</span> <span style="color: #000000;">=</span> repeatedElements<span style="color: #009900;">&#40;</span><span style="color: #000088;">$arrayParaChequear</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span>
&nbsp;
<span style="color: #990000;">print_r</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$repetidos</span><span style="color: #009900;">&#41;</span><span style="color: #000000;">;</span></pre></div></div>

<p>Y la salida del ejemplo anterior seria la siguiente</p>

<div class="wp_syntax"><div class="code"><pre class="plain" style="font-family:monospace;">Array
(
    [0] =&gt; Array
        (
            [value] =&gt; chau
            [count] =&gt; 2
        )
&nbsp;
    [1] =&gt; Array
        (
            [value] =&gt; hola
            [count] =&gt; 2
        )
&nbsp;
    [2] =&gt; Array
        (
            [value] =&gt; 1
            [count] =&gt; 2
        )
&nbsp;
)</pre></div></div>

<p>Como veran, es un array, cuyas claves son</p>
<p>&#8216;value&#8217;, que contiene el valor que se repitio<br />
&#8216;count&#8217; la cantidad de veces que aparecio</p>
<p>Espero que les sirva! <img src='http://www.cristianperez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' />  Saludos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/12/31/contar-elementos-repetidos-en-un-array/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Instalar RabbitVCS en Mandriva Linux</title>
		<link>http://www.cristianperez.com/2009/12/03/instalar-rabbitvcs-en-mandriva-linux/</link>
		<comments>http://www.cristianperez.com/2009/12/03/instalar-rabbitvcs-en-mandriva-linux/#comments</comments>
		<pubDate>Thu, 03 Dec 2009 04:13:16 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[Tutoriales]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=173</guid>
		<description><![CDATA[RabbitVCS es un cliente SVN compatible con Gnome (GTK) e integrado a nautilus. En este post vamos a tratar algunos FIXES con respecto a las instrucciones de instalacion oficiales, ya que en mi caso no funcionaron correctamente. Lo primero que vamos a hacer es abrir un terminal, y loguearnos como root corriendo el siguiente comando]]></description>
			<content:encoded><![CDATA[<p>RabbitVCS es un cliente SVN compatible con Gnome (GTK) e integrado a nautilus.</p>
<p>En este post vamos a tratar algunos FIXES con respecto a las instrucciones de instalacion oficiales, ya que en mi caso no funcionaron correctamente.<br />
<span id="more-173"></span><br />
Lo primero que vamos a hacer es abrir un terminal, y loguearnos como root corriendo el siguiente comando</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">su</span></pre></div></div>

<p>Una vez hecho esto, ejecutamos el siguiente comando</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">urpmi nautilus-python python-pysvn python-configobj subversion meld python-dbus python-setuptools</pre></div></div>

<p>Luego de esto, ya tenemos todo listo, descargamos el Tarball para distribuciones independientes de la pagina oficial, en esta direccion</p>
<p><a href="http://wiki.rabbitvcs.org/wiki/download">http://wiki.rabbitvcs.org/wiki/download</a></p>
<p>Ahora lo descomprimimos y desde el terminal vamos hasta la carpeta donde se descomprimieron los archivos y ejecutamos</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">python setup.py <span style="color: #c20cb9; font-weight: bold;">install</span></pre></div></div>

<p>Luego de que la instalacion termine, ejecutamos</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #c20cb9; font-weight: bold;">killall</span> nautilus</pre></div></div>

<p>y luego para concluir</p>

<div class="wp_syntax"><div class="code"><pre class="bash" style="font-family:monospace;">nautilus</pre></div></div>

<p>Bueno espero que les haya servido! <img src='http://www.cristianperez.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>Saludos!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/12/03/instalar-rabbitvcs-en-mandriva-linux/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Cosas sobre Linux para imprimir y guardar en nuestra mochila de trabajo</title>
		<link>http://www.cristianperez.com/2009/10/27/cosas-sobre-linux-para-imprimir-y-guardar-en-nuestra-mochila-de-trabajo/</link>
		<comments>http://www.cristianperez.com/2009/10/27/cosas-sobre-linux-para-imprimir-y-guardar-en-nuestra-mochila-de-trabajo/#comments</comments>
		<pubDate>Tue, 27 Oct 2009 17:29:10 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=162</guid>
		<description><![CDATA[Encontre navegando por ahi unos documentos que me gustaron mucho, muy cortos y utiles sobre datos que uno por ahi no recuerda o necesita conocer sobre la plataforma Linux Los dejo para descargar aqui: UNIX/Linux Command Reference (Lista de Comandos) The One Page Linux Manual (Sobre comandos mas utilizados, algo de permisos sobre archivos, y]]></description>
			<content:encoded><![CDATA[<p>Encontre navegando por ahi unos documentos que me gustaron mucho, muy cortos y utiles sobre datos que uno por ahi no recuerda o necesita conocer sobre la plataforma Linux<span id="more-162"></span></p>
<p>Los dejo para descargar aqui:</p>
<p><a href="http://www.cristianperez.com/wp-content/uploads/2009/10/fwunixref.pdf">UNIX/Linux Command Reference</a> (Lista de Comandos)</p>
<p><a href="http://www.cristianperez.com/wp-content/uploads/2009/10/The-One-Page-Linux-Manual.pdf">The One Page Linux Manual</a> (Sobre comandos mas utilizados, algo de permisos sobre archivos, y alguna que otra cosa mas)</p>
<p><a href="http://www.cristianperez.com/wp-content/uploads/2009/10/LINUX-Admin-Quick-Reference.pdf">LINUX Admin Quick Reference</a> (Sobre directorios, archivos de configuracion, modulos, entre otros)</p>
<p>Saludos, espero que les sea util</p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/10/27/cosas-sobre-linux-para-imprimir-y-guardar-en-nuestra-mochila-de-trabajo/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Open Komodo&#8230;.. Simplemente&#8230;.muy kómodo!</title>
		<link>http://www.cristianperez.com/2009/10/16/open-komodo-simplemente-muy-komodo/</link>
		<comments>http://www.cristianperez.com/2009/10/16/open-komodo-simplemente-muy-komodo/#comments</comments>
		<pubDate>Fri, 16 Oct 2009 21:14:43 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[General]]></category>
		<category><![CDATA[Programacion General]]></category>
		<category><![CDATA[Software]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[php]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=157</guid>
		<description><![CDATA[Komodo IDE es, valga la redundancia, un IDE (Integrated Development Environment) orientado principalmente al desarrollo para la Web&#8230; El proyecto esta liderado por la empresa Active State y su licencia paga. Ahora bien, el proyecto Open Komodo inicia cuando Active State decide abrir parte del código de Komodo IDE para crear Komodo Edit, el cual es un]]></description>
			<content:encoded><![CDATA[<p><strong><img class="alignright size-full wp-image-158" title="komodo-logo" src="http://www.cristianperez.com/wp-content/uploads/2009/10/komodo.png" alt="komodo-logo" width="128" height="128" />Komodo IDE</strong> es, valga la redundancia, un IDE (Integrated Development Environment) orientado principalmente al desarrollo para la Web&#8230;<br />
El proyecto esta liderado por la empresa <a href="http://www.activestate.com/">Active State</a> y su licencia paga.<span id="more-157"></span></p>
<p>Ahora bien, el proyecto <strong>Open Komodo</strong> inicia cuando Active State decide abrir parte del código de Komodo IDE para crear <strong>Komodo Edit</strong>, el cual es un editor de código basado en el mencionado IDE.</p>
<p>Por si a alguno le quedan dudas Open Komodo no es el editor en si, sino que es el Repositorio del código fuente de Komodo Edit.</p>
<p>Ahora bien, mi experiencia con Komodo edit es 100% positiva!.</p>
<p>Algunas características que para mi son esenciales y que Komodo Edit cumple a la perfección son:</p>
<ul>
<li>Un buen coloreado del código</li>
<li>Inteligence, funcionando para mi gusto A LA PERFECCIÓN no solo en PHP, sino también para Javascript (Punto muy importante ya que no hay buenos editores de javascript y menos aun que cuenten con Inteligence ), HTML, XML, que son los que he testeado hasta el momento</li>
<li>Soporte para extensiones&#8230; Punto muy bueno!&#8230; Las mismas las pueden encontrar aca <a href="http://community.activestate.com/addons">http://community.activestate.com/addons</a></li>
</ul>
<p>Y muchos puntos mas que creo que no hace falta destacar porque no son mas que lo que se encuentra en el común denominador de los editores de código mas famosos.</p>
<p>Si vale recalcar la potencia de este editor, que cumple mis expectativas en un 100%, y que por cierto es también Multi-plataforma, lo cual no limita al usuario a usar este software bajo la plataforma que cada uno elija&#8230;</p>
<p>Recomiendo que lo prueben, y bueno, si a alguien le interesa o ya lo ha hecho, pueden probar también la versión Trial de Komodo IDE, la cual integra muchas ventajas mas, como debugger, syntax checking, HTML preview, entre muchisimas otras, y comentar que tal les ha ido!&#8230;</p>
<p>Para los que les interese les dejo la pagina del proyecto</p>
<p><a href="http://www.openkomodo.com/">http://www.openkomodo.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/10/16/open-komodo-simplemente-muy-komodo/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>&#8220;En linux no hay juegos&#8221;&#8230;. Error!</title>
		<link>http://www.cristianperez.com/2009/10/13/en-linux-no-hay-juegos-error/</link>
		<comments>http://www.cristianperez.com/2009/10/13/en-linux-no-hay-juegos-error/#comments</comments>
		<pubDate>Tue, 13 Oct 2009 15:23:20 +0000</pubDate>
		<dc:creator>Cristián</dc:creator>
				<category><![CDATA[GNU/Linux]]></category>
		<category><![CDATA[General]]></category>

		<guid isPermaLink="false">http://www.cristianperez.com/?p=150</guid>
		<description><![CDATA[Encontre este programa navegando por la web, el cual presenta un listado de los mejores juegos al parecer para la plataforma linux&#8230; Se trata de DJL, un programa que actuá como gestor de juegos, desde el cual podrás ver un preview del juego elegido, y descargarlo desde ahí mismo si te interesa Una alternativa organizada]]></description>
			<content:encoded><![CDATA[<p>Encontre este programa navegando por la web, el cual presenta un listado de los mejores juegos al parecer para la plataforma linux&#8230;<br />
<span id="more-150"></span><br />
<a href="http://www.cristianperez.com/wp-content/uploads/2009/10/pantallazo-djl-127.png"><img src="http://www.cristianperez.com/wp-content/uploads/2009/10/pantallazo-djl-127-300x244.png" alt="pantallazo-djl-127" title="pantallazo-djl-127" width="300" height="244" class="alignright size-medium wp-image-153" /></a><br />
Se trata de DJL, un programa que actuá como gestor de juegos, desde el cual podrás ver un preview<br />
del juego elegido, y descargarlo desde ahí mismo si te interesa </p>
<p>Una alternativa organizada y simple para mi gusto de buscar juegos sin demasiados problemas</p>
<p>Les dejo el sitio oficial <a href="http://en.djl-linux.org">http://en.djl-linux.org</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.cristianperez.com/2009/10/13/en-linux-no-hay-juegos-error/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
