supermerc Posted February 28, 2009 Share Posted February 28, 2009 Hi, I have a cURL script that goes to a page, the page is a sort of vault that displays a bunch of items in the form of images. I want to be able to get the path to each of those image. I managed to do so using this code: <?php $data = $result2; $pattern = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i"; preg_match_all($pattern, $data, $images); ?> The problem is that does that for the WHOLE page and I just want it to do it for the items in the vault. Here is the page http://legacyow.comze.com/get_vault.php the items are all the broken images together near the center of the page. Thanks Link to comment https://forums.phpfreaks.com/topic/147303-preg_match-but-for-only-a-certan-area/ Share on other sites More sharing options...
thebadbad Posted February 28, 2009 Share Posted February 28, 2009 You just have to find a unique string before and after the vault, and then cut the relevant source code out with e.g. substr() in combination with strpos(). Example: Source: <?php $data = '<html> <unique combination of tags> vault text with images <another unique combination of tags> </html>'; $start = strpos($data, '<unique combination of tags>'); $length = strpos($data, '<another unique combination of tags>') - $start; $vault = substr($data, $start, $length); //vault holds "vault text with images" ?> Link to comment https://forums.phpfreaks.com/topic/147303-preg_match-but-for-only-a-certan-area/#findComment-773240 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.