I'm working on a project in which i need to extract <img> tags and their <alt> tags from a html page using PHP code. There are many imagess in the html page and i have to write the code in such a way that it extracts the image and its alt tag from that html page. Can anyone help me in this? If anyone has a code for it please say it to me. Thankx
To get all img tags from your text use: preg_match_all('/<img(.*)>/U', $str, $out); PHP: You will get the results in $out array (you will actually get two sets of arrays: one with all between <img and the next > including these delimiters, and one set with the text between <img and the next > excluding these delimiters.