偏轉(zhuǎn)輔助函數(shù)?
偏轉(zhuǎn)輔助函數(shù)文件包含的函數(shù)容許你改變**英文**詞匯到復(fù)數(shù),單數(shù),駝峰式大小寫(xiě),等等。
通用函數(shù)?
下面的函數(shù)是通用的:
-
singular
($string)? 參數(shù): - $string (string) – 輸入 string
返回: 單數(shù)單詞
返回類(lèi)型: string
改變復(fù)數(shù)單詞為單數(shù)。例如:
echo singular('dogs'); // 打印出 'dog'
-
plural
($string)? 參數(shù): - $string (string) – 輸入 string
返回: 復(fù)數(shù)單詞
返回類(lèi)型: string
改變單數(shù)單詞為復(fù)數(shù)。例如:
echo plural('dog'); // 打印出 'dogs'
-
counted
($count, $string)? 參數(shù): - $count (int) – Number of items
- $string (string) – Input string
返回: A singular or plural phrase
返回類(lèi)型: string
Changes a word and its count to a phrase. 例如:
echo counted(3, 'dog'); // 打印出 '3 dogs'
-
camelize
($string)? 參數(shù): - $string (string) – 輸入 string
返回: 駝峰化 string
返回類(lèi)型: string
由空格或者下劃線(xiàn)改變單詞分割的字符串為駝峰式大小寫(xiě)。例如:
echo camelize('my_dog_spot'); // 打印出 'myDogSpot'
-
pascalize
($string)? 參數(shù): - $string (string) – Input string
返回: Pascal case string
返回類(lèi)型: string
Changes a string of words separated by spaces or underscores to Pascal case, which is camel case with the first letter capitalized. 例如:
echo pascalize('my_dog_spot'); // 打印出 'MyDogSpot'
-
underscore
($string)? 參數(shù): - $string (string) – 輸入 string
返回: 字符串包含下劃線(xiàn)代替空格
返回類(lèi)型: string
由多空格和下劃線(xiàn)帶來(lái)多樣的單詞分割。事例:
echo underscore('my dog spot'); // 打印出 'my_dog_spot'
-
humanize
($string[, $separator = '_'])? 參數(shù): - $string (string) – 輸入 string
- $separator (string) – 輸入分隔符Input separator
返回: 人性化的 string
返回類(lèi)型: string
由空格帶來(lái)復(fù)合單詞的分割并在他們中間添加空格。每個(gè)單詞用大寫(xiě)書(shū)寫(xiě)。
事例:
echo humanize('my_dog_spot'); // 打印出 'My Dog Spot'
使用波折號(hào)代替下劃線(xiàn):
echo humanize('my-dog-spot', '-'); // 打印出 'My Dog Spot'
-
is_pluralizable
($word)? 參數(shù): - $word (string) – 輸入 string
返回: 如果單詞為可數(shù)的則 TRUE 否則 FALSE
返回類(lèi)型: bool
多次核對(duì)假設(shè)約定的單詞已經(jīng)有一個(gè)復(fù)數(shù)版本。事例:
is_pluralizable('equipment'); // 返回 FALSE
-
dasherize
($string)? 參數(shù): - $string (string) – 輸入 string
返回: 底線(xiàn)轉(zhuǎn)換 string
返回類(lèi)型: string
在 string 里取代帶著波折號(hào)的下劃線(xiàn)。事例:
dasherize('hello_world'); // 返回 'hello-world'
-
ordinal
($integer)? 參數(shù): - $integer (int) – integer 決定詞尾
返回: 順序的詞尾
返回類(lèi)型: string
返回的詞尾應(yīng)該添加一個(gè)數(shù)目去表示位置例如 1st, 2nd, 3rd, 4th. 事例:
ordinal(1); // 返回 'st'
-
ordinalize
($integer)? 參數(shù): - $integer (int) – integer 序號(hào)
返回: 序數(shù)化 integer
返回類(lèi)型: string
轉(zhuǎn)換數(shù)目為順序的字符串過(guò)去總是指示位置例如 1st, 2nd, 3rd, 4th. 事例:
ordinalize(1); // 返回 '1st'