- substr: documentation ( source)
- print_r: documentation ( source)
- trim: documentation ( source)
- strrpos: documentation ( source)
- strtoupper: documentation ( source)
<?php
$value = ['district' => 'М. КРИВИЙ РІГ ЦЕНТРАЛЬНОМІСЬКИЙ РАЙОН'];
$value['town'] = $value['district'];
$value['district'] = substr(strtoupper($value['district']),0, strrpos(strtoupper($value['district']),' РАЙОН')-1);
$value['town']= substr(trim($value['district']),strrpos(trim($value['district']),' ')+1).' РАЙОН';
$value['district'] = substr(trim($value['district']),0,strrpos(trim($value['district']),' '));
print_r($value);