[Solved] Strip Image Addresses from HTML
Posted: Mon Aug 09, 2004 11:25 am
I've making a function for the footer file of my PHP pages that tells me how big the page was in KB.
I've got the (HTML) contents of the page in a string called $contents and I'd like to be able to take all the bits ending in .jpg" or .gif" and get the addresses for each of them.
For example, here is a small HTML page:
Can anyone who can use preg_match (or whatever) knock me up a quick function that will take that code above stick the image addresses into an array, like:
Any help much appreciated.
I've got the (HTML) contents of the page in a string called $contents and I'd like to be able to take all the bits ending in .jpg" or .gif" and get the addresses for each of them.
For example, here is a small HTML page:
Code: Select all
<html>
<head>
<title>Bob</title>
</head>
<body>
<img src="images/bob.jpg">
<br><br>
<img src="images/hector.gif" alt="Hector Rocks">
</body>
</html>Code: Select all
1 => images/bob.jpg
2 => images/hector.gif