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

编码风格变换

WBOY
Release: 2016-06-13 11:59:43
Original
1017 people have browsed it

编码风格转换
一种编码风格,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 />
Copy after login

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template