Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I properly split a PATH variable in PHP?

I want to split

$path = getenv('PATH');

into its components. How do I determine the separator char in an os-dependent fashion?

like image 628
fabiangebert Avatar asked Aug 11 '09 10:08

fabiangebert


2 Answers

You can use the PATH_SEPARATOR constant, then the DIRECTORY_SEPARATOR constant to split the path if needed. See Directory Predefined Constants

like image 146
Greg Avatar answered Sep 22 '22 04:09

Greg


Use the PATH_SEPARATOR constant.

like image 30
RaYell Avatar answered Sep 21 '22 04:09

RaYell