note 54244 deleted from function.substr by mazzanet

From: Date: Tue, 28 Jun 2005 10:18:00 +0000
Subject: note 54244 deleted from function.substr by mazzanet
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-91074@lists.php.net to get a copy of this message
Note Submitter: bourharas_zakaria at yahoo dot fr ---- Une fonction très simple qui pend comme paramètre l’url exemple :'http://www.php.net/exemple/index3.php' et retourne 'http://www.php.net/exemple/' <?php //---------------------------------------------------------- function reverse_strrchr($haystack, $needle) { $pos = strrpos($haystack, $needle); //retourne la dernière occurrence du caractère $needle if($pos === false) { return $haystack; } return substr($haystack, 0, $pos + 1); //Prend un morceau de $haystack (la première partie avant la dernière occurrence du caractère $needle) } //---------------------------------------------------------- function prem_modul_url($url){ $p = reverse_strrchr($url, '/') ; return $p; } //---------------------------------------------------------- $string = "/path/to/the/file/filename.php"; $f=prem_modul_url($string) ; echo $f ;// $f = /path/to/the/file/ //----------------------------------------------------------?>

« previous php.notes (#91074) next »