i have this function to shorten the filename if it is over 23 characters to "...", but i want to keep the files extension
function formatNameFile($nama) {
return strlen($nama) > 23 ? mb_strimwidth($nama, 0, 23, "...") : $nama;
}
echo formatNameFile('resume_t8ffvwnjxibqwhu5l0mk1jwu9mmb4b_3.pdf');
my output
resume_t8ffvwnjxibqw...
expected output
resume_t8ffvwnjxibqw...pdf
how do i achieve this? please help.