summaryrefslogtreecommitdiffstats
path: root/system/helpers
diff options
context:
space:
mode:
authorEric Barnes <eric@ericlbarnes.com>2011-12-09 17:27:51 +0100
committerEric Barnes <eric@ericlbarnes.com>2011-12-09 17:27:51 +0100
commitcde712ce354dcfd69f9c5e2b56ef7d6f1206d11a (patch)
tree85aaa507b2ca7f6ef7bb0650a38bcf1442899b64 /system/helpers
parentdb351e6672d2f6d6d2015ad8b053d910911c2bc4 (diff)
Added ability to change the separator value in the humanize function
Diffstat (limited to 'system/helpers')
-rw-r--r--system/helpers/inflector_helper.php18
1 files changed, 9 insertions, 9 deletions
diff --git a/system/helpers/inflector_helper.php b/system/helpers/inflector_helper.php
index 513a9c54f..3393bda8f 100644
--- a/system/helpers/inflector_helper.php
+++ b/system/helpers/inflector_helper.php
@@ -5,9 +5,9 @@
* An open source application development framework for PHP 5.1.6 or newer
*
* NOTICE OF LICENSE
- *
+ *
* Licensed under the Open Software License version 3.0
- *
+ *
* This source file is subject to the Open Software License (OSL 3.0) that is
* bundled with this package in the files license.txt / license.rst. It is
* also available through the world wide web at this URL:
@@ -84,7 +84,7 @@ if ( ! function_exists('singular'))
'/(n)ews$/' => '\1\2ews',
'/([^u])s$/' => '\1',
);
-
+
foreach ($singular_rules as $rule => $replacement)
{
if (preg_match($rule, $result))
@@ -115,7 +115,7 @@ if ( ! function_exists('plural'))
function plural($str, $force = FALSE)
{
$result = strval($str);
-
+
$plural_rules = array(
'/^(ox)$/' => '\1\2en', // ox
'/([m|l])ouse$/' => '\1ice', // mouse, louse
@@ -196,20 +196,20 @@ if ( ! function_exists('underscore'))
/**
* Humanize
*
- * Takes multiple words separated by underscores and changes them to spaces
+ * Takes multiple words separated by the separator and changes them to spaces
*
* @access public
- * @param string
+ * @param string $str
+ * @param string $separator
* @return str
*/
if ( ! function_exists('humanize'))
{
- function humanize($str)
+ function humanize($str, $separator = '_')
{
- return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
+ return ucwords(preg_replace('/['.$separator.']+/', ' ', strtolower(trim($str))));
}
}
-
/* End of file inflector_helper.php */
/* Location: ./system/helpers/inflector_helper.php */ \ No newline at end of file