3v4l.org

run code in 200+ php & hhvm versions
Bugs & Features
<?php $str = '<p height="200px;"> <img alt="Fahrrad Alt-Tag" src="http://localhost/mediafiles/Bilder/diamant-e-bike.jpg" height="250px" style="float: left; width: 300px; height: 189px; margin-left: 10px; margin-right: 10px;"> <br> <div style="height:200px;"> <img alt="Fahrrad Alt-Tag" src="http://localhost/mediafiles/Bilder/diamant-e-bike.jpg" height="250px" style="float: left; width: 300px; height: 189px; margin-left: 10px; margin-right: 10px;" class="google"> </div>'; function e24_img_responsive($html) { /* preg_match_all("~<img\s*(?:style\s*\=\s*[\'\"](.*?)[\'\"].*?\s*|class\s*\=\s*[\'\"](.*?)[\'\"].*?\s*|src\s*\=\s*[\'\"](.*?)[\'\"].*?\s*|alt\s*\=\s*[\'\"](.*?)[\'\"].*?\s*|width\s*\=\s*[\'\"](.*?)[\'\"].*?\s*|height\s*\=\s*[\'\"](.*?)[\'\"].*?\s*)+.*?>~", $html, $aImageTags); foreach($aImageTags[0] as $index => $string) { $new_string = $string; // style tag found if(!empty($aImageTags[1][$index])) { $new_string = preg_replace("~height:.*;~") } // class tag found if(!empty($aImageTags[2][$index])) { var_dump($aImageTags[2][$index]); } // height tag found if(!empty($aImageTags[6][$index])) { var_dump($aImageTags[6][$index]); } } */ $dom = new DOMDocument(); $dom->loadHTML($html); $images = $dom->getElementsByTagName('img'); while($img = $images->item($i++)) { foreach($img->attributes as $attr) { echo $attr->name . " " . $attr->value . "<br />"; } } } e24_img_responsive($str); ?>
based on evSOB
Output for 5.6.0 - 5.6.30, 7.0.0 - 7.3.0beta1
Notice: Undefined variable: i in /in/RoICZ on line 38 alt Fahrrad Alt-Tag<br />src http://localhost/mediafiles/Bilder/diamant-e-bike.jpg<br />height 250px<br />style float: left; width: 300px; height: 189px; margin-left: 10px; margin-right: 10px;<br />alt Fahrrad Alt-Tag<br />src http://localhost/mediafiles/Bilder/diamant-e-bike.jpg<br />height 250px<br />style float: left; width: 300px; height: 189px; margin-left: 10px; margin-right: 10px;<br />class google<br />
Output for hhvm-3.12.14 - 3.17.3
Notice: Undefined variable: i in /in/RoICZ on line 38 Warning: item() expects parameter 1 to be integer, null given in /in/RoICZ on line 38