Created
February 12, 2013 20:51
-
-
Save hectorip/4773260 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$datos=<<<EOT | |
4 | |
Estimado presidente | |
Debemos platicar sobre esta situacion su pueblo esta muy hinchado | |
y no pensamos plantar mas bombas | |
queremos paz DE UNA VEZ LE DIGO Que haga lo que haga no seremos sus esclavoz | |
EOT; | |
$lineas=preg_split("/((\r?\n)|(\r\n?))/", $datos); | |
$n_lineas=$lineas[0]; | |
for($i=1; $i<=$n_lineas;$i++){ | |
$nueva_linea=""; | |
foreach(preg_split("/ +/", $lineas[$i]) as $palabra){ | |
if(preg_match('/[pP].*[rR]$/',$palabra)){ | |
$n_letras=strlen($palabra); | |
$nueva_linea.=str_pad("", $n_letras,"#")." "; | |
} | |
else if(preg_match('/^[hH].*(?=([oO]))/',$palabra)){ | |
$n_letras=strlen($palabra); | |
$nueva_linea.=str_pad("", $n_letras,"#")." "; | |
} | |
else { | |
$nueva_linea.=strtoupper($palabra)." "; | |
} | |
} | |
echo $nueva_linea."<br/>"; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment