Re: suffixSwap function
| From: | Alexandertje | Date: | Fri, 06 Oct 2000 10:16:45 +0000 |
| Subject: | Re: suffixSwap function | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-18847@lists.php.net to get a copy of this message | ||
On Thu, Oct 05, 2000 at 11:57:48PM -0500, Matt McClanahan wrote:
> A fair warning though, this won't work for files that have multiple
> periods in them.
how about:
function suffixSwap($str, $x)
{
$pos = strrpos($str,".");
$tmp = substr($str,0,is_int($pos)?($pos-1):strlen($str));
return "$tmp.$x";
}
(untested)
Alex