3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<'HTML' <div class="blockImg imgRight"> <img src="customs/2/pictures/home.png"> <figcaption>Une légende</figcaption> </div> HTML; // on ajoute la structure manquante pour préciser l'encodage $html = <<<HTML <html><head><meta charset="utf-8"/></head><body>$html</body></html> HTML; $dom = new \DOMDocument; $dom->loadHTML($html, LIBXML_NOERROR); $context = $dom->getElementsByTagName('div')[0]; $xp = new \DOMXPath($dom); // on extrait la valeur de l'attribut class tout en vérifiant la présence de la classe "blockImg" $classAttrValue = $xp->evaluate( 'string(@class[contains(concat(" ", normalize-space(.), " "), " blockImg ")])', $context ); if ($classAttrValue && preg_match('~ \b img (?: Right | Left ) \b ~x', $classAttrValue, $m)) { $class = $m[0]; $src = $xp->evaluate('string(img/@src)', $context); $filename = basename($src); $caption = $xp->evaluate('string(figcaption)', $context); echo $class, PHP_EOL, $src, PHP_EOL, $filename, PHP_EOL, $caption, PHP_EOL; }

Here you find the average performance (time & memory) of each version. A grayed out version indicates it didn't complete successfully (based on exit-code).

VersionSystem time (s)User time (s)Memory (MiB)
8.5.30.0060.01219.59
8.5.20.0080.00920.27
8.5.10.0090.01017.06
8.5.00.0140.00720.42
8.4.180.0130.00922.27
8.4.170.0130.00924.01
8.4.160.0120.01024.12
8.4.150.0020.00014.05
8.4.140.0130.00818.09
8.4.130.0150.00618.85
8.4.120.0120.00724.54
8.4.110.0040.00621.15
8.4.100.0080.01219.31
8.4.90.0120.00922.79
8.4.80.0140.00619.43
8.4.70.0090.01019.30
8.4.60.0150.00419.19
8.4.50.0110.00920.84
8.4.40.0100.01018.18
8.4.30.0130.00718.81
8.4.20.0170.00321.68
8.4.10.0280.00620.06
8.3.300.0110.00921.21
8.3.290.0110.00921.20
8.3.280.0130.00919.01
8.3.270.0110.01216.90
8.3.260.0140.00616.95
8.3.250.0120.00719.18
8.3.240.0140.00617.51
8.3.230.0040.00517.11
8.3.220.0130.00719.09
8.3.210.0130.00616.93
8.3.200.0040.00417.01
8.3.190.0100.00917.50
8.3.180.0130.00619.46
8.3.170.0150.00317.29
8.3.160.0120.00618.78
8.3.150.0110.00717.36
8.3.140.0100.01018.84
8.3.130.0180.00016.90
8.3.120.0140.00517.23
8.3.110.0160.00316.75
8.3.100.0190.00317.03
8.3.90.0220.00017.11
8.3.80.0150.00616.97
8.3.70.0200.00417.06
8.3.60.0200.00017.30
8.3.50.0140.00716.98
8.3.40.0130.00417.98
8.3.30.0210.00018.04
8.3.20.0150.00417.80
8.3.10.0180.00018.04
8.3.00.0120.00617.93
8.2.300.0130.00818.61
8.2.290.0070.00522.61
8.2.280.0130.00719.01
8.2.270.0120.00917.04
8.2.260.0090.00916.59
8.2.250.0140.00417.11
8.2.240.0130.00516.81
8.2.230.0140.00517.01
8.2.220.0130.00416.95
8.2.210.0110.00716.78
8.2.200.0170.00016.88
8.2.190.0160.00316.73
8.2.180.0150.00316.82
8.2.170.0120.00618.06
8.2.160.0080.01118.01
8.2.150.0100.00718.20
8.2.140.0110.00918.06
8.2.130.0180.00017.97
8.2.120.0070.01117.77
8.2.110.0130.00618.17
8.2.100.0150.00417.79
8.2.90.0170.00318.10
8.2.80.0110.00817.81
8.2.70.0160.00518.15
8.2.60.0090.00917.78
8.2.50.0150.00417.98
8.2.40.0100.00718.20
8.2.30.0110.00618.07
8.2.20.0140.00517.85
8.2.10.0130.00317.97
8.2.00.0070.01018.01
8.1.340.0100.01022.06
8.1.320.0080.00216.85

preferences:
29.86 ms | 403 KiB | 5 Q