For the single-byte encoded (binary) strings:
substr($username, 0, 1);
// or
$username[0] ?? null;
For the multi-byte encoded strings, such as UTF-8:
mb_substr($username, 0, 1);
For the single-byte encoded (binary) strings:
substr($username, 0, 1);
// or
$username[0] ?? null;
For the multi-byte encoded strings, such as UTF-8:
mb_substr($username, 0, 1);
Add new comment