From cde712ce354dcfd69f9c5e2b56ef7d6f1206d11a Mon Sep 17 00:00:00 2001 From: Eric Barnes Date: Fri, 9 Dec 2011 11:27:51 -0500 Subject: Added ability to change the separator value in the humanize function --- system/helpers/inflector_helper.php | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'system/helpers') 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 -- cgit v1.2.3-24-g4f1b