Динамически, если вы хотите удалить (а) часть (и) из (а) фиксированного индекса (ов) строки, используйте эту функцию:
/*
* Remove index/indexes from a string, delimited by a space (or something else).
* First, divides the string by delimiter and holds divided parts as an array.
* If $index is an array, it removes all indexes of the divided string;
* otherwise (i.e. has an int value), it removes just that index of the string.
* At last, it joins all string parts together and return it as a string.
* Note: If you want to use this function in PHP5, remove scalar type hints
* (i.e. keywords before function arguments).
* Note: For PHP versions lower than 7.0, remove scalar type hints (i.e. the
* types before each argument) and the return type.
*/
function remove_from_str(string $str, $index, string $delimiter = " "): string
{
// String parts
$strParts = explode($delimiter, $str);
// Remove indexes from string parts
if (is_array($index))
foreach ($index as $i)
$strParts[(int)$i] = null;
else
$strParts[(int)$index] = null;
// Remove null values, to prevent duplicating delimiter
$strParts = array_filter($strParts);
// Join all parts together and return it
return implode($delimiter, $strParts);
}
Для вашей цели:
remove_from_str("REGISTER 11223344 here", 1);
// Output: REGISTER here
Одним из способов его использования является выполнение командоподобных строк, в которых вы знаете их структуру.