note 84825 modified in function.substr by danbrown

From: Date: Thu, 31 Jul 2008 22:08:03 +0000
Subject: note 84825 modified in function.substr by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-142992@lists.php.net to get a copy of this message
Here is a quick function to get the substring of a string up to and including the last occurrence of $needle <?php function substrtruncate($string, $needle) { return substr($string, 0, strrpos($string, $needle)+1); } $current_dir = substrtruncate($_SERVER['SCRIPT_NAME'], '/'); ?> --was-- Here is a quick function to get the substring of a string up to and including the last occurrence of $needle function substrtruncate($string, $needle) { return substr($string, 0, strrpos($string, $needle)+1); } $current_dir = substrtruncate($_SERVER['SCRIPT_NAME'], '/'); http://php.net/manual/en/function.substr.php

« previous php.notes (#142992) next »