How do I remove the last comma from a string using PHP? December 24, 2022 by Tarik Use the rtrim function: rtrim($my_string, ','); The Second parameter indicates the character to be deleted.