PHP function returns path from array of directory names, without double pathname separators.

Sometimes in configuration files, I might have to set up various directory paths, from which a valid pathname has to be constructed. Often it is not clear whether an initial or final slash (”/”) is required, and sometimes different parts of the program may have different requirements.