How do I properly split a PATH variable in PHP?

前端 未结 4 785
囚心锁ツ
囚心锁ツ 2021-01-11 15:43

I want to split

$path = getenv(\'PATH\');

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

4条回答
  •  无人及你
    2021-01-11 16:41

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

提交回复
热议问题