3v4l.org

run code in 300+ PHP versions simultaneously
<?php $text = "ABC01 ABC02 ABC03 ABC04 ABC05 ABC06 "; $text = explode("\n",str_replace("\r", "", $text)); $text = array_filter($text, 'trim'); $key = array_search("ABC04", $text); $text[$key-1] .= " - " . $text[$key]; Unset($text[$key]); Echo implode("<br>\n", $text);

preferences:
127.37 ms | 408 KiB | 5 Q