How to remove string trailing path separator in PHP

1 Answer

0 votes
// Example string with trailing path separator
$path = "example/path/project/";

// Remove the trailing path separator
$trimmedPath = rtrim($path, "/");

// Output the result
echo $trimmedPath; 



/*
run:

example/path/project

*/

 



answered Jun 16, 2025 by avibootz

Related questions

...