From 08cae63859339faaac8809c6a1d1fceed5f2909f Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Tue, 10 Feb 2009 20:03:29 +0000 Subject: "optimized" explode_name() --- system/libraries/Image_lib.php | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'system/libraries') diff --git a/system/libraries/Image_lib.php b/system/libraries/Image_lib.php index 0e7f21435..2896c9e07 100644 --- a/system/libraries/Image_lib.php +++ b/system/libraries/Image_lib.php @@ -1437,26 +1437,10 @@ class CI_Image_lib { */ function explode_name($source_image) { - $x = explode('.', $source_image); - $ret['ext'] = '.'.end($x); - - $name = ''; - - $ct = count($x)-1; - - for ($i = 0; $i < $ct; $i++) - { - $name .= $x[$i]; - - if ($i < ($ct - 1)) - { - $name .= '.'; - } - } - - $ret['name'] = $name; - - return $ret; + $ext = strrchr($source_image, '.'); + $name = ($ext === FALSE) ? $source_image : substr($source_image, 0, -strlen($ext)); + + return array('ext' => $ext, 'name' => $name); } // -------------------------------------------------------------------- -- cgit v1.2.3-24-g4f1b