Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- // Array to store data attribute values
- $dataArray = array();
- // Your HTML with object tags
- $html = '
- <object data="https://lh3.googleusercontent.com/pw/ADCreHftjFHGck3jAfULwxkYHZwONXzrWPTNyHjkR5HSPFbIbLNYe_p4vq07qD5OpcpUVS5DvJC35gEyS2C5MMM2jY57-T1zRdZL2x-HLX4kUvtr-qtbNLAa=w1920-h1080"></object>
- <object data="https://lh3.googleusercontent.com/pw/ADCreHfh1X0-aveKY7t_czfeMtGLWm3T5Fjb-0jSfx-EpCB3M4fRq9LQPALZR1s9Elyn63YKhdzP7YUX-7VXIyWseTt-IxZu0Umz7x4MS53ZcJFlYNZvw7Xf=w1920-h1080"></object>
- <object data="https://lh3.googleusercontent.com/pw/ADCreHeQC0Jm7crtJs2rdlYgr16aWobX4tDMC4ru6JesUqri33b5yNmMOObK-F1UM-ANycHQ_q8WSuX0qi6hxbzKM5kks2O2pR5caFEry1CvtI0lxC9QHDDS=w1920-h1080"></object>
- ';
- // Parsing HTML to get data attribute values
- $doc = new DOMDocument();
- $doc->loadHTML($html);
- // Get all <object> tags
- $objects = $doc->getElementsByTagName('object');
- // Loop through each <object> tag and extract data attribute values
- foreach ($objects as $object) {
- $data = $object->getAttribute('data');
- // Add data attribute value to the PHP array
- $dataArray[] = $data;
- }
- // Printing the PHP array with data attribute values
- //print_r($dataArray);
- // Loop through the array and print each item inside the HTML structure
- foreach ($dataArray as $data) {
- echo '<a href="' . $data . '"><img src="' . $data . '" alt="" title=""/></a><br>';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement