1 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
\r
5 * An open source application development framework for PHP 4.3.2 or newer
\r
7 * @package CodeIgniter
\r
8 * @author ExpressionEngine Dev Team
\r
9 * @copyright Copyright (c) 2008, EllisLab, Inc.
\r
10 * @license http://codeigniter.com/user_guide/license.html
\r
11 * @link http://codeigniter.com
\r
12 * @since Version 1.0
\r
16 // ------------------------------------------------------------------------
\r
19 * CodeIgniter Inflector Helpers
\r
21 * @package CodeIgniter
\r
22 * @subpackage Helpers
\r
24 * @author ExpressionEngine Dev Team
\r
25 * @link http://codeigniter.com/user_guide/helpers/directory_helper.html
\r
29 // --------------------------------------------------------------------
\r
34 * Takes a plural word and makes it singular
\r
40 if ( ! function_exists('singular'))
\r
42 function singular($str)
\r
44 $str = strtolower(trim($str));
\r
45 $end = substr($str, -3);
\r
49 $str = substr($str, 0, strlen($str)-3).'y';
\r
51 elseif ($end == 'ses')
\r
53 $str = substr($str, 0, strlen($str)-2);
\r
57 $end = substr($str, -1);
\r
61 $str = substr($str, 0, strlen($str)-1);
\r
69 // --------------------------------------------------------------------
\r
74 * Takes a singular word and makes it plural
\r
81 if ( ! function_exists('plural'))
\r
83 function plural($str, $force = FALSE)
\r
85 $str = strtolower(trim($str));
\r
86 $end = substr($str, -1);
\r
90 $str = substr($str, 0, strlen($str)-1).'ies';
\r
92 elseif ($end == 's')
\r
108 // --------------------------------------------------------------------
\r
113 * Takes multiple words separated by spaces or underscores and camelizes them
\r
119 if ( ! function_exists('camelize'))
\r
121 function camelize($str)
\r
123 $str = 'x'.strtolower(trim($str));
\r
124 $str = ucwords(preg_replace('/[\s_]+/', ' ', $str));
\r
125 return substr(str_replace(' ', '', $str), 1);
\r
129 // --------------------------------------------------------------------
\r
134 * Takes multiple words separated by spaces and underscores them
\r
140 if ( ! function_exists('underscore'))
\r
142 function underscore($str)
\r
144 return preg_replace('/[\s]+/', '_', strtolower(trim($str)));
\r
148 // --------------------------------------------------------------------
\r
153 * Takes multiple words separated by underscores and changes them to spaces
\r
159 if ( ! function_exists('humanize'))
\r
161 function humanize($str)
\r
163 return ucwords(preg_replace('/[_]+/', ' ', strtolower(trim($str))));
\r
168 /* End of file inflector_helper.php */
\r
169 /* Location: ./system/helpers/inflector_helper.php */