<?php
// USE THIS FUNCTION TO USE AUTOMATICALLY LinkExtractor CLASS
require( "LinkExtractor.class.php" );
function linkExtractor( $what, $url = false ) {
// andr3a 18/06/2004 [ www.3site.it ]
// linkExtractor( $string_url_or_file [, true/false ] )
// true if $string_or_url is an url or a file
// false or anything if is a string
$myLinks = &new LinkExtractor();
if( $url == false ) {
$myLinks->parseString( $what );
}
elseif( $url == true ) {
if( $myLinks->parseUrl( $what ) == false ) {
return false;
}
}
return $myLinks->getLinks();
}
// EXAMPLE
$url = "http://www.php.net/"; // site to parse
$arrayLinks = &linkExtractor( $url, true );
if( $arrayLinks != false ) {
for( $a = 0, $b = count( $arrayLinks ); $a < $b; $a++ ) {
echo $arrayLinks[$a]."<br />";
}
}
?>
|