3v4l.org

run code in 500+ PHP versions simultaneously
<?php $str = '<?xml version="1.0" encoding="utf-8"?> <products> <item> <ItemID>01</ItemID> <ItemName>Book</ItemName> </item> <Product> <ProductID>01</ProductID> <ProductName>Paper</ProductName> </Product>'; $lines = explode("\n", $str); echo implode("\n", array_map(function ($line) { $trimmedLine = trim($line); if ($trimmedLine == "<Product>") { return $trimmedLine; } return $line; }, $lines));
Output for 7.4.0 - 7.4.33, 8.0.1 - 8.0.30, 8.1.0 - 8.1.34, 8.2.0 - 8.2.30, 8.3.0 - 8.3.30, 8.4.1 - 8.4.21, 8.5.0 - 8.5.7
<?xml version="1.0" encoding="utf-8"?> <products> <item> <ItemID>01</ItemID> <ItemName>Book</ItemName> </item> <Product> <ProductID>01</ProductID> <ProductName>Paper</ProductName> </Product>

preferences:
90.5 ms | 1290 KiB | 4 Q