Extraction of image attributes like ‘src’, ‘alt’, ‘height’, ‘width’ etc from a HTML page using PHP. This task can be done using the following steps.
- Loading HTML content in a variable(DOM variable).
- Selecting each image in that document.
- Selecting attribute and save it’s content to a variable.
- Output as HTML img object or as plain values as required.
Example 1: This example displays the image object as output.
Example 2: This example displays the attribute of an image object.
- PHP | extract() Function
- Perl | Extract IP Address from a String using Regex
- Extract unique objects by attribute from array of objects.
- HTML Course | Structure of an HTML Document
- HTML Course | Basics of HTML
- HTML | DOM HTML Object
- HTML | dl Tag
- HTML | th Tag
- HTML | col Tag
- HTML | br Tag
- Div Tag | HTML
- HTML | <ul> Tag
- HTML vs XML
- HTML | b Tag
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.