<?PHP function strrevpos($instr, $needle) { $rev_pos = strpos (strrev($instr), strrev($needle)); if ($rev_pos===false) return false; else return strlen($instr) - $rev_pos - strlen($needle); } function after_last ($this, $inthat) { if (!is_bool(strrevpos($inthat, $this))) return substr($inthat, strrevpos($inthat, $this)+strlen($this)); } function finddir($v) { return substr($v,0,strpos($v,after_last('/', $v))); } echo finddir($_SERVER['SCRIPT_NAME']); ?>
Non testé.
after_last de biohazard at online dot ge :
http://php.belnet.be/manual/fr/function.substr.php