- substr: documentation ( source)
- preg_match: documentation ( source)
- print_r: documentation ( source)
<?php
$stringRegex = "/([aA][0-9]+)/";
$schema = [
'a26UserId',
'a17Passwd',
'cAccountChannel',
'a256PcInfo1'
];
$result = [];
foreach ($schema as $currentType) {
if (preg_match($stringRegex, $currentType, $matches)) {
$result[] = $matches[1];
} else {
$result[] = substr($currentType, 0, 1);
}
}
print_r($result);