Created
January 31, 2015 23:53
-
-
Save bran921007/24bbbd4a39df999bc20c to your computer and use it in GitHub Desktop.
Extraer urls con PHP - expresion regular
This file contains hidden or 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 | |
$cadena = file_get_contents('http://www.taringa.net'); | |
function extraerURLs($cadena){ | |
$regex = '/https?\:\/\/[^\" ]+/i'; | |
preg_match_all($regex, $cadena, $partes); | |
return ($partes[0]); | |
} | |
// Llamamos a la función y le pasamos la cadena a buscar | |
$urls = extraerURLs($cadena); | |
// Listamos los resultados | |
foreach($urls as $url){ | |
echo $url.'<br />'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
por ahi lo use para algo, maybe(?