0
文字列を置換する際にucwords()を使用する方法が分かっている人はいらっしゃいますか はスペースでアンダースコアを使用していますか?私は、...PHP Ucwords on underders
// this_string_contents -> ThisStringContents
preg_replace('/(?:^|_)(.?)/e',"strtoupper('$1')",$string);
そして、これらがあまりにも対称であればそれはいいだろう
// ThisStringContents -> this_string_contents
strtolower(preg_replace('/([^A-Z])([A-Z])/', "$1_$2", $string));
逆にそれを行いますにpreg_replaceを持っていますが、間に 必要なスペースを追加しません上記 は、あなたの代わりにstr_replace
を使用ツー持っていない場合は、正規表現を使用しないでください。この
* this_is_a_string -> ThisIsAString -> this_is_astring
* GetURLForString -> get_urlfor_string -> GetUrlforString
ucwords(str_replace( "_"、 ""、$文字列)) –
CakePHPの偉大な語形のクラスを持っています。 [Documentation](http://book.cakephp.org/1.3/ja/view/1479/Class-methods) - [API(ソースあり)](http://api11.cakephp.org/class_inflector.html) –
'WoW - > Wo_w'はどうですか? –