<?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>Manuel &#124; empty &#187; validar rut</title>
	<atom:link href="http://manuel.radiohead.cl/tag/validar-rut/feed/" rel="self" type="application/rss+xml" />
	<link>http://manuel.radiohead.cl</link>
	<description>Comenzando a escribir...</description>
	<lastBuildDate>Wed, 14 Apr 2010 14:05:08 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Función para validar RUT en PHP5.3 o inferior</title>
		<link>http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/</link>
		<comments>http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/#comments</comments>
		<pubDate>Wed, 07 Oct 2009 20:03:42 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[programacion]]></category>
		<category><![CDATA[chile]]></category>
		<category><![CDATA[php]]></category>
		<category><![CDATA[php 5.3]]></category>
		<category><![CDATA[validar rut]]></category>

		<guid isPermaLink="false">http://manuel.radiohead.cl/?p=25</guid>
		<description><![CDATA[Muchas, por no decir todas, de las funciones que hay en internet para validar el RUT son compatibles con PHP...]]></description>
			<content:encoded><![CDATA[<p>Muchas, por no decir todas, de las funciones que hay en internet para validar  el RUT son compatibles con PHP 5.2.X o inferiores.</p>
<p>En PHP 5.3 se dieron de baja varias funciones con el fin de &#8220;preparar&#8221; el núcleo para PHP 6. Por este motivo me decidí a re-escribir el código de la función que utilizaba para validar el rut.</p>
<p><span id="more-25"></span></p>
<div class="codecolorer-container php default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><table cellspacing="0" cellpadding="0"><tbody><tr><td style="padding:5px;text-align:center;color:#888888;background-color:#EEEEEE;border-right: 1px solid #9F9F9F;font: normal 12px/1.4em Monaco, Lucida Console, monospace;"><div>1<br />2<br />3<br />4<br />5<br />6<br />7<br />8<br />9<br />10<br />11<br />12<br />13<br />14<br />15<br />16<br />17<br />18<br />19<br />20<br />21<br />22<br />23<br />24<br />25<br />26<br />27<br />28<br />29<br />30<br />31<br />32<br />33<br />34<br />35<br />36<br /></div></td><td><div class="php codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">&nbsp; &nbsp; <span style="color: #009933; font-style: italic;">/**<br />
&nbsp; &nbsp; &nbsp;* Funcion para validar RUT compatible con PHP5.3 o inferior<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @license &nbsp; &nbsp; BSD<br />
&nbsp; &nbsp; &nbsp;* @author&nbsp; &nbsp; &nbsp; Manuel Diego Paillafil Gamboa<br />
&nbsp; &nbsp; &nbsp;* @link&nbsp; &nbsp; &nbsp; &nbsp; http://manuel.radiohead.cl/<br />
&nbsp; &nbsp; &nbsp;* @email &nbsp; &nbsp; &nbsp; manuel@radiohead.cl<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @version &nbsp; &nbsp; 1.0<br />
&nbsp; &nbsp; &nbsp;* @date&nbsp; &nbsp; &nbsp; &nbsp; 07/10/2009<br />
&nbsp; &nbsp; &nbsp;* <br />
&nbsp; &nbsp; &nbsp;* @param string<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;* @return bool<br />
&nbsp; &nbsp; &nbsp;*<br />
&nbsp; &nbsp; &nbsp;*/</span><br />
&nbsp; &nbsp; <span style="color: #000000; font-weight: bold;">public</span> static <span style="color: #000000; font-weight: bold;">function</span> rut<span style="color: #009900;">&#40;</span><span style="color: #000088;">$rut</span><span style="color: #009900;">&#41;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$rut</span>&nbsp; &nbsp; <span style="color: #339933;">=</span> &nbsp; <a href="http://www.php.net/strtoupper"><span style="color: #990000;">strtoupper</span></a><span style="color: #009900;">&#40;</span><a href="http://www.php.net/preg_replace"><span style="color: #990000;">preg_replace</span></a><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'{\.|,|-}'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #000088;">$rut</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sub_rut</span><span style="color: #339933;">=</span> &nbsp; <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rut</span><span style="color: #339933;">,</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rut</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$sub_dv</span> <span style="color: #339933;">=</span> &nbsp; <a href="http://www.php.net/substr"><span style="color: #990000;">substr</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$rut</span><span style="color: #339933;">,-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$x</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">2</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$s</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><a href="http://www.php.net/strlen"><span style="color: #990000;">strlen</span></a><span style="color: #009900;">&#40;</span><span style="color: #000088;">$sub_rut</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">&gt;=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span><span style="color: #000088;">$i</span><span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$x</span>&nbsp; <span style="color: #339933;">=</span> &nbsp; <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">7</span><span style="color: #009900;">&#41;</span> ? <span style="color: #cc66cc;">2</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$x</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$s</span>&nbsp; <span style="color: #339933;">+=</span>&nbsp; <span style="color: #000088;">$sub_rut</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">*</span><span style="color: #000088;">$x</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$x</span><span style="color: #339933;">++;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dv</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">11</span> <span style="color: #339933;">-</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$s</span><span style="color: #339933;">%</span><span style="color:#800080;">11</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000088;">$dv</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dv</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">10</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'K'</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$dv</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">11</span><span style="color: #009900;">&#41;</span> ? <span style="color: #0000ff;">'0'</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$dv</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; <br />
&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$dv</span><span style="color: #339933;">==</span><span style="color: #000088;">$sub_dv</span><span style="color: #009900;">&#41;</span> ? <span style="color: #009900; font-weight: bold;">TRUE</span> <span style="color: #339933;">:</span> <span style="color: #009900; font-weight: bold;">FALSE</span><span style="color: #339933;">;</span> <br />
&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></td></tr></tbody></table></div>


<div class="shr-bookmarks shr-bookmarks-expand shr-bookmarks-center">
<ul class="socials">
		<li class="shr-delicious">
			<a href="http://www.shareaholic.com/api/share/?title=Funci%C3%B3n+para+validar+RUT+en+PHP5.3+o+inferior&amp;link=http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/&amp;notes=Muchas%2C%20por%20no%20decir%20todas%2C%20de%20las%20funciones%20que%20hay%20en%20internet%20para%20validar%20%20el%20RUT%20son%20compatibles%20con%20PHP%205.2.X%20o%20inferiores.%0D%0A%0D%0AEn%20PHP%205.3%20se%20dieron%20de%20baja%20varias%20funciones%20con%20el%20fin%20de%20%22preparar%22%20el%20n%C3%BAcleo%20para%20PHP%206.%20Por%20este%20motivo%20me%20decid%C3%AD%20a%20re-escribir%20el%20c%C3%B3digo%20de%20la%20funci%C3%B3n%20que%20ut&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=2&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="shr-facebook">
			<a href="http://www.shareaholic.com/api/share/?title=Funci%C3%B3n+para+validar+RUT+en+PHP5.3+o+inferior&amp;link=http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/&amp;notes=Muchas%2C%20por%20no%20decir%20todas%2C%20de%20las%20funciones%20que%20hay%20en%20internet%20para%20validar%20%20el%20RUT%20son%20compatibles%20con%20PHP%205.2.X%20o%20inferiores.%0D%0A%0D%0AEn%20PHP%205.3%20se%20dieron%20de%20baja%20varias%20funciones%20con%20el%20fin%20de%20%22preparar%22%20el%20n%C3%BAcleo%20para%20PHP%206.%20Por%20este%20motivo%20me%20decid%C3%AD%20a%20re-escribir%20el%20c%C3%B3digo%20de%20la%20funci%C3%B3n%20que%20ut&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=5&amp;tags=&amp;ctype=" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="shr-gmail">
			<a href="http://www.shareaholic.com/api/share/?title=Funci%C3%B3n+para+validar+RUT+en+PHP5.3+o+inferior&amp;link=http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/&amp;notes=Muchas%2C%20por%20no%20decir%20todas%2C%20de%20las%20funciones%20que%20hay%20en%20internet%20para%20validar%20%20el%20RUT%20son%20compatibles%20con%20PHP%205.2.X%20o%20inferiores.%0D%0A%0D%0AEn%20PHP%205.3%20se%20dieron%20de%20baja%20varias%20funciones%20con%20el%20fin%20de%20%22preparar%22%20el%20n%C3%BAcleo%20para%20PHP%206.%20Por%20este%20motivo%20me%20decid%C3%AD%20a%20re-escribir%20el%20c%C3%B3digo%20de%20la%20funci%C3%B3n%20que%20ut&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=52&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Email this via Gmail">Email this via Gmail</a>
		</li>
		<li class="shr-googlebookmarks">
			<a href="http://www.shareaholic.com/api/share/?title=Funci%C3%B3n+para+validar+RUT+en+PHP5.3+o+inferior&amp;link=http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/&amp;notes=Muchas%2C%20por%20no%20decir%20todas%2C%20de%20las%20funciones%20que%20hay%20en%20internet%20para%20validar%20%20el%20RUT%20son%20compatibles%20con%20PHP%205.2.X%20o%20inferiores.%0D%0A%0D%0AEn%20PHP%205.3%20se%20dieron%20de%20baja%20varias%20funciones%20con%20el%20fin%20de%20%22preparar%22%20el%20n%C3%BAcleo%20para%20PHP%206.%20Por%20este%20motivo%20me%20decid%C3%AD%20a%20re-escribir%20el%20c%C3%B3digo%20de%20la%20funci%C3%B3n%20que%20ut&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=&amp;service=74&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Add this to Google Bookmarks">Add this to Google Bookmarks</a>
		</li>
		<li class="shr-twitter">
			<a href="http://www.shareaholic.com/api/share/?title=Funci%C3%B3n+para+validar+RUT+en+PHP5.3+o+inferior&amp;link=http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/&amp;notes=Muchas%2C%20por%20no%20decir%20todas%2C%20de%20las%20funciones%20que%20hay%20en%20internet%20para%20validar%20%20el%20RUT%20son%20compatibles%20con%20PHP%205.2.X%20o%20inferiores.%0D%0A%0D%0AEn%20PHP%205.3%20se%20dieron%20de%20baja%20varias%20funciones%20con%20el%20fin%20de%20%22preparar%22%20el%20n%C3%BAcleo%20para%20PHP%206.%20Por%20este%20motivo%20me%20decid%C3%AD%20a%20re-escribir%20el%20c%C3%B3digo%20de%20la%20funci%C3%B3n%20que%20ut&amp;short_link=&amp;shortener=google&amp;shortener_key=&amp;v=1&amp;apitype=1&amp;apikey=8afa39428933be41f8afdb8ea21a495c&amp;source=Shareaholic&amp;template=%24%7Btitle%7D+-+%24%7Bshort_link%7D&amp;service=7&amp;tags=&amp;ctype=" rel="nofollow" class="external" title="Tweet This!">Tweet This!</a>
		</li>
</ul><div style="clear: both;"></div><div class="shr-getshr" style="visibility:hidden;font-size:10px !important"><a target="_blank" href="http://www.shareaholic.com/?src=pub">Get Shareaholic</a></div><div style="clear: both;"></div></div>

]]></content:encoded>
			<wfw:commentRss>http://manuel.radiohead.cl/2009/funcion-para-validar-rut-en-php5-3-o-inferior/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

