- array_search: documentation ( source)
- implode: documentation ( source)
- str_replace: documentation ( source)
- explode: documentation ( source)
- array_filter: documentation ( source)
<?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);