Ej.1 Obtener el title de una pagina web desde una URL
function getTitle($Url){ $str = file_get_contents($Url); if(strlen($str)>0){ preg_match("/\(.*)\<\/title\>/",$str,$title); return $title[1]; } </pre> Ej.2 validar url de id youtube<br /> <pre class="brush: js;"> function validate_url($url) { preg_match('#^(?:https?://)?(?:www\.)?(?:youtube\.com(?:/embed/|/v/|/watch\?v=))([\w-]{11})(?:.+)?$#x', $url, $r); return (isset($r[1]) && !empty($r[1])) ? $r[1] : false; } </pre> y listo!
No hay comentarios:
Publicar un comentario