Home / PHP Tips Generated By ChatGPT / Trimming Characters from a String in PHP Trim specific characters from the beginning and end of a string with trim(). Source Code $text = "/Hello, World!/"; $trimmed = trim($text, "/"); echo $trimmed; // Outputs: Hello, World!