summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorPhil Sturgeon <email@philsturgeon.co.uk>2011-08-14 20:10:55 +0200
committerPhil Sturgeon <email@philsturgeon.co.uk>2011-08-14 20:10:55 +0200
commitd8ef630f2d4d32eee998969e548d36dc629340d4 (patch)
tree92a509fda736fb9a6a119dcb6b16c40607ed0fa5 /system/helpers
parent02d45b56c57f6cf9f8c0fabe7f8b7ed761bd5a9b (diff)
parentc2a37669107829b032b08562e784416713f569b1 (diff)
Fixed conflict.
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/string_helper.php15
1 files changed, 15 insertions, 0 deletions
diff --git a/system/helpers/string_helper.php b/system/helpers/string_helper.php
index 7765bba31..2f928a7d1 100644
--- a/system/helpers/string_helper.php
+++ b/system/helpers/string_helper.php
@@ -243,6 +243,21 @@ 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
+ * @return string
+ */
+function increment_string($str, $first = 1, $separator = '_')
+{
+ preg_match('/(.+)'.$separator.'([0-9]+)$/', $str, $match);
+
+ return isset($match[2]) ? $match[1].$separator.($match[2] + 1) : $str.$separator.$first;
+}
+
+// ------------------------------------------------------------------------
+
+/**
* Alternator
*
* Allows strings to be alternated. See docs...