$path = \'/home/to//my///site\';
I am trying to remove unnecessary forward slashes /
from the path above
I am trying to get this
You could use the build-in function realpath() for stripping slashes of existing files. But you will always end up with a canonicalized absolute pathname.
Please note that this function returns an error if the file does not exist.
Some important remarks from the docs:
realpath() expands all symbolic links and resolves references to '/./', '/../' and extra '/' characters in the input path and returns the canonicalized absolute pathname.
And
On windows realpath() will change unix style paths to windows style.