3v4l.org

run code in 300+ PHP versions simultaneously
<?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); ?>
Output for 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.7
Warning: Undefined variable $i in /in/RoICZ on line 38 Deprecated: DOMNodeList::item(): Passing null to parameter #1 ($index) of type int is deprecated 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 8.0.0 - 8.0.30
Warning: 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 5.6.38, 7.0.0 - 7.0.33, 7.1.0 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.31, 7.4.0 - 7.4.33
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 7.3.32 - 7.3.33
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 />

preferences:
182.33 ms | 402 KiB | 246 Q