我想知道是否有可能使用CakePHP的函數來重寫字符串。CakePHP重寫字符串
例如,FormHelper完全符合我的需求:「this_stuff」變爲輸入標籤的「This Stuff」。
我想這有一個方法,但我找不到任何東西。
在此先感謝。
解決方案 變形器::人文化($下劃線)
Input: apple_pie, some_thing, people_person
Output: Apple Pie, Some Thing, People Person
我想知道是否有可能使用CakePHP的函數來重寫字符串。CakePHP重寫字符串
例如,FormHelper完全符合我的需求:「this_stuff」變爲輸入標籤的「This Stuff」。
我想這有一個方法,但我找不到任何東西。
在此先感謝。
解決方案 變形器::人文化($下劃線)
Input: apple_pie, some_thing, people_person
Output: Apple Pie, Some Thing, People Person
您可以使用變形器:
static **Inflector::camelize($underscored)**
Input: Apple_pie, some_thing, people_person
Output: ApplePie, SomeThing, PeoplePerson
http://book.cakephp.org/2.0/en/core-utility-libraries/inflector.html
太好了,謝謝。我將使用Inflector :: humanize($ underscored) 輸入:apple_pie,some_thing,people_person 輸出:Apple Pie,Some Thing,People Person – Owlbertz
[變形器(HTTP://書.cakephp.org/2.0/en/core-utility-libraries/inflector.html#Inflector :: pluralize)class will d o這個給你 –