3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <div> <section> <p>text</p> <p>text</p> </section> <section> <h2>text</h2> <p>text</p> <p>text</p> </section> </div> HTML; $dom = new \DOMDocument; libxml_use_internal_errors(true); $dom->loadHTML($html, LIBXML_HTML_NOIMPLIED | LIBXML_HTML_NODEFDTD); $xpath = new DOMXpath($dom); $count = 0; foreach ($xpath->query('//section/*') as $node) { $node->nodeValue = ' {{ $t("ccpaRightsText' . ++$count . '" }} '; } echo substr($dom->saveHTML($dom), 5, -7);
Output for 8.0.1 - 8.0.30, 8.1.0 - 8.1.33, 8.2.0 - 8.2.29, 8.3.0 - 8.3.25, 8.4.1 - 8.4.12
<section> <p> {{ $t("ccpaRightsText1" }} </p> <p> {{ $t("ccpaRightsText2" }} </p> </section> <section> <h2> {{ $t("ccpaRightsText3" }} </h2> <p> {{ $t("ccpaRightsText4" }} </p> <p> {{ $t("ccpaRightsText5" }} </p> </section>

preferences:
93.36 ms | 407 KiB | 5 Q