Created
November 25, 2013 09:12
-
-
Save anytizer/7638630 to your computer and use it in GitHub Desktop.
Extract src and href
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 | |
$path = '/home/USER/public_html'; | |
function resources($path) | |
{ | |
$resources = array( | |
'file' => $path, | |
'href' => array(), | |
'src' => array(), | |
'success' => false, | |
); | |
$fc = file_get_contents($path); | |
$hrefs = array(); | |
preg_match_all('/href="(.*?)"/is', $fc, $hrefs); | |
$resources['href'] = $hrefs[1]; | |
$srcs = array(); | |
preg_match_all('/src="(.*?)"/is', $fc, $srcs); | |
$resources['src'] = $srcs[1]; | |
$resources['success'] = (count($resources['src']) || count($resources['href'])); | |
return $resources; | |
} | |
chdir($path); | |
$files = glob('*.php'); | |
foreach($files as $f => $file) | |
{ | |
$resources = resources($file); | |
if($resources['success']) | |
{ | |
print_r($resources); | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment