3v4l.org

run code in 300+ PHP versions simultaneously
<?php $str = "<para>From the New York Times</para> <para>Instacart, a two-year-old grocery delivery company, announced a $44 million round of financing on Monday led by Andreessen Horowitz. Three venture capital firms that previously invested in the company, Sequoia Capital, Khosla Ventures and Canaan Partners, participated in the latest round.</para> <para>The company, which is based in San Francisco, lets customers shop online from grocery stores in their area. The orders are filled by other people who have signed up to be shoppers and who receive a cut of the delivery fees. Information about a store’s inventory comes from store managers and from the shoppers. The company says it can have groceries delivered within an hour.</para>"; $dom = new DOMDocument; $dom->preserveWhiteSpace = false; $dom->formatOutput = true; libxml_use_internal_errors(true); $dom->loadHTML($str, LIBXML_HTML_NODEFDTD | LIBXML_HTML_NOIMPLIED); $xpath = new DOMXPath($dom); $secondPara = $xpath->query('//para[2]'); $secondPara->item(0)->setAttribute('align', 'left'); echo $dom->saveHTML();

preferences:
37.22 ms | 402 KiB | 5 Q