3v4l.org

run code in 300+ PHP versions simultaneously
<?php function applyHLToSiblings(DOMDocument $D){ $words[0] = "cart"; /* $words[1] = "car"; $words[2] = "cartel"; $words[3] = "art"; $words[4] = "drug"; $words[5] = "drugs"; $words[6] = "rug"; $words[7] = "rugs"; */ $ps = function($siblingsContainer, $searchString, $name) use($D){ foreach($siblingsContainer->getChildNodes() as $node){ if($node instanceof DOMText){ if(mb_strlen($node->textContent, "UTF-8") >= mb_strlen($searchString)){ $o = mb_strpos($node->textContent, $searchString); if($o !== false){ $before = mb_substr($node->textContent, 0, $o); $wrap = mb_substr($node->textContent, $o, mb_strlen($searchString, "UTF-8)); $after = mb_substr($node->textContent, $o); print_r($before); print_r($wrap); print_r($after); } } } } }; foreach($words as $name => $word) $ps($container->documentNode, $word, $name); } $x = new DOMDocument(); $x->loadXML("<data>drugs cartel</data>"); applyHLToSiblings($x);

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)
5.6.150.0100.06018.29
5.6.140.0070.08318.29
5.6.130.0130.03018.24
5.6.120.0130.06321.03
5.6.110.0070.07020.98
5.6.100.0070.07721.11
5.6.90.0100.08020.97
5.6.80.0070.04020.55
5.5.300.0030.05018.04
5.5.290.0070.08017.93
5.5.280.0100.08320.74
5.5.270.0070.03720.98
5.5.260.0070.07720.88
5.5.250.0070.06320.52
5.5.240.0300.06320.17

preferences:
141.43 ms | 1394 KiB | 7 Q