Update to CodeIgniter 2.1.0
This commit is contained in:
17
system/helpers/string_helper.php
Executable file → Normal file
17
system/helpers/string_helper.php
Executable file → Normal file
@@ -242,6 +242,23 @@ if ( ! function_exists('random_string'))
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Add's _1 to a string or increment the ending number to allow _2, _3, etc
|
||||
*
|
||||
* @param string $str required
|
||||
* @param string $separator What should the duplicate number be appended with
|
||||
* @param string $first Which number should be used for the first dupe increment
|
||||
* @return string
|
||||
*/
|
||||
function increment_string($str, $separator = '_', $first = 1)
|
||||
{
|
||||
preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
|
||||
|
||||
return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Alternator
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user