Home >Backend Development >PHP Tutorial >编码风格变换

编码风格变换

WBOY
WBOYOriginal
2016-06-13 11:59:431021browse

编码风格转换
一种编码风格,MyScoreIphone
转换成另一种编码风格 my_score_iphone
应该怎样做,分别使用java和php实现

其中,php使用函数

请多指教!
------解决方案--------------------

<br /><?php<br /><br />$funcname = 'MyScoreIphone';<br />$newfuncname = change($funcname);<br />echo $funcname.'<br>';<br />echo $newfuncname;<br /><br />function change($str){<br />    $newstr = preg_replace_callback('/[A-Z]{1}/', 'f', $str);<br />    return substr($newstr, 1);<br />}<br /><br />function f($str){<br />    return '_'.strtolower($str[0]);<br />}<br /><br />?><br />

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn