nasser bahaj Posted April 27, 2010 Share Posted April 27, 2010 hi all is there any way to check images on my page are linked or not ? example : my page html code : <html><body> <img src="img1.gif" /><br /> <a href="www.site1.com"><img src="img2.gif" /></a><br /> <img src="img3.gif" /><br /> </body></html> in the page above I have 3 images one of them linked and the others not linked. so I want a way to get array of linked images and another array of not linked images . array1 ( [0]=>img1.gif [1]=>img3.gif ) array2 ( [0]=>img2.gif ) I think this can done by regular expression but I could not do it . best regards . Quote Link to comment https://forums.phpfreaks.com/topic/199896-how-to-check-if-image-is-linked/ Share on other sites More sharing options...
cags Posted April 27, 2010 Share Posted April 27, 2010 If you mean you wish a list of img tags that are locatted inside of a tags, then yes it could be done with Regex. It's possible better to do it with xpath though. At it's most basic you could write a Regex something like this... <img[^>]*src="([^"]+)"[^>]*></a> ...to find the src value of img tags directly between </a> tags. You could improve this with lookaround assertions. Quote Link to comment https://forums.phpfreaks.com/topic/199896-how-to-check-if-image-is-linked/#findComment-1049276 Share on other sites More sharing options...
nasser bahaj Posted April 28, 2010 Author Share Posted April 28, 2010 thank you Mr cags problem solved; best regards Quote Link to comment https://forums.phpfreaks.com/topic/199896-how-to-check-if-image-is-linked/#findComment-1049824 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.