Last active
August 29, 2015 14:06
-
-
Save carlosjunod/82f08c421fdd52d8c2ee to your computer and use it in GitHub Desktop.
Obtener UF / UTM / Dolar fecha
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 | |
// fuente: http://www.chw.net/foro/webmasters/287574-extraer-uf-php-solucion-definitiva.html | |
function indicadores($tipo,$limite, $fin,$fuente){ | |
$domain = strstr($fuente, $limite); | |
$domain = $domain; | |
switch ($tipo) { | |
case "fecha": | |
$domain=split('\n',$domain); | |
return strip_tags(str_replace("al ","",str_replace($fin,"",$domain[0]))); | |
break; | |
case "uf": | |
$domain=strip_tags($domain); | |
$domain=split('\n',$domain); | |
return str_replace(array("\r\n", "\n", "\r", "\t","&","UF"," ","$"),"",$domain[0]); | |
break; | |
case "utm": | |
$domain=strip_tags($domain); | |
$domain=split('\n',$domain); | |
return str_replace(array("\r\n", "\n", "\r", "\t","&","UTM"," ","$"),"",$domain[0]); | |
break; | |
case "dolar": | |
$domain=strip_tags($domain); | |
$domain=split('\n',$domain); | |
return str_replace(array("\r\n", "\n", "\r", "\t","&","lar Observado"," ","$"),"",$domain[0]); | |
break; | |
case 2: | |
echo "i equals 2"; | |
break; | |
} | |
} | |
$fuente = file_get_contents('http://www.bancoestado.cl/bancoestado/indiceseconomicos/indicadores.asp'); | |
echo "Fecha:".indicadores('fecha','al ', ")</fo",$fuente); | |
echo "<br>UF:".indicadores('uf','UF</a></font></td>', "z",$fuente); | |
echo "<br>UTM:".indicadores('utm','UTM</a></font></td>', "z",$fuente); | |
echo "<br>Dolar:".indicadores('dolar','lar Observado</a></font></td>', "z",$fuente); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment