November 9, 2012
List connected files as array when we call a file with php?
Question by AnzaVR
What I am trying to achieve, when I open a website, it starts a network activity by loading images, swf files, css file etc. Is there any way in php to get a list of those resources as array?
Answer by Starx
You can use regular expression to parse the links once you have all HTML markups.
Here is an example to get the CSS request:
$regexp = "<links[^>]*href=("??)([^" >]*?)\1[^>]*/>";
preg_match_all("/$regexp/siU", $input, $matches);
var_dump($matches);
In the same way get scripts resources, image request, and iframe request.