fork download
  1. <?php
  2.  
  3. $removePath = '/path/to/exist-not' ;
  4. $includepath = '.' . PATH_SEPARATOR . '/path/to/exist-not' . PATH_SEPARATOR . '/path/to/exist';
  5. $wordsPath = str_replace(PATH_SEPARATOR, ' ', $includepath);
  6. $result = preg_replace('/\b' . preg_quote($removePath, '/') . '\b/i', '', $wordsPath);
  7. var_dump(str_replace(' ', PATH_SEPARATOR, $result));
  8.  
  9. $paths = array_flip(explode(PATH_SEPARATOR, $includepath));
  10. if(isset($paths[$removePath])){
  11. unset($paths[$removePath]);
  12. }
  13. $includepath = implode(PATH_SEPARATOR, array_flip($paths));
  14. var_dump($includepath);
  15.  
  16.  
Success #stdin #stdout 0.02s 52432KB
stdin
Standard input is empty
stdout
string(35) ".:/path/to/exist-not:/path/to/exist"
string(16) ".:/path/to/exist"