blob: cc46a185174386a09cb9677fd5b992f0bd04d5ac (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
|
################
Inflector Helper
################
The Inflector Helper file contains functions that permits you to change
words to plural, singular, camel case, etc.
.. contents:: Page Contents
Loading this Helper
===================
This helper is loaded using the following code
::
$this->load->helper('inflector');
The following functions are available:
singular()
==========
Changes a plural word to singular. Example
::
$word = "dogs";
echo singular($word); // Returns "dog"
plural()
========
Changes a singular word to plural. Example
::
$word = "dog";
echo plural($word); // Returns "dogs"
To force a word to end with "es" use a second "true" argument.
::
$word = "pass";
echo plural($word, TRUE); // Returns "passes"
camelize()
==========
Changes a string of words separated by spaces or underscores to camel
case. Example
::
$word = "my_dog_spot";
echo camelize($word); // Returns "myDogSpot"
underscore()
============
Takes multiple words separated by spaces and underscores them. Example
::
$word = "my dog spot";
echo underscore($word); // Returns "my_dog_spot"
humanize()
==========
Takes multiple words separated by underscores and adds spaces between
them. Each word is capitalized. Example
::
$word = "my_dog_spot";
echo humanize($word); // Returns "My Dog Spot"
To use dashes instead of underscores
::
$word = "my-dog-spot";
echo humanize($word, '-'); // Returns "My Dog Spot"
|