
How to remove the last comma from the string in PHP?

remove last comma from string
names = names.replaceAll(",$", "");
//Or a simple substring:
if (names.endsWith(",")) {
names = names.substring(0, names.length() - 1);
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
