Reputation: 2623
I want to split
$path = getenv('PATH');
into its components. How do I determine the separator char in an os-dependent fashion?
Upvotes: 11
Views: 11021
Reputation: 253308
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.
Upvotes: 0
Reputation: 106322
I know this works for the include_path - not sure about getenv('PATH'):
$paths = split(PATH_SEPARATOR, getenv('PATH'));
Upvotes: 3
Reputation: 321578
You can use the PATH_SEPARATOR
constant, then the DIRECTORY_SEPARATOR
constant to split the path if needed.
See Directory Predefined Constants
Upvotes: 21