I want to split
$path = getenv('PATH');
into its components. How do I determine the separator char in an os-dependent fashion?
I want to split
$path = getenv('PATH');
into its components. How do I determine the separator char in an os-dependent fashion?
You can use the PATH_SEPARATOR
constant, then the DIRECTORY_SEPARATOR
constant to split the path if needed.
See Directory Predefined Constants
I know this works for the include_path - not sure about getenv('PATH'):
$paths = split(PATH_SEPARATOR, getenv('PATH'));
I seem to remember that Windows will accept both forward- and back-slashes as a file-separator, so you may not have to worry about it.