function makeTextIndex( $string ) {
return strtoupper(
preg_replace(
'/[^a-zA-Z0-9_-]/',
'',
$string
)
);
}
substr(makeTextIndex( $country['en'] ), 0, 4);
<?php
$country = [
'en' => 'Georgia',
];
function makeTextIndex($string) {
$clearText = strtoupper(preg_replace('/[^a-zA-Z0-9_-]/', '', $string));
$TextIndex = substr($clearText, 0, 2) . "-" . substr($clearText, 2, 2);
return $TextIndex;
}
var_dump(makeTextIndex( $country['en'] ));