美文网首页
用PHP将字符串php_content替换成Php Conten

用PHP将字符串php_content替换成Php Conten

作者: followyounger1 | 来源:发表于2017-06-01 10:49 被阅读6次

<?php
$str = 'wang_zhao_yang';
$str = str_replace('_', ' ', $str);
$str1 = ucwords($str);
$str2 = str_replace(' ', '', $str1);
echo $str2;

其他
ucfirst — 将字符串的首字母转换为大写

<?php
$foo = 'hello world!';
$foo = ucfirst($foo); // Hello world!

$bar = 'HELLO WORLD!';
$bar = ucfirst($bar); // HELLO WORLD!
$bar = ucfirst(strtolower($bar)); // Hello world!
?>

lcfirst — 使一个字符串的第一个字符小写

<?php
$foo = 'HelloWorld';
$foo = lcfirst($foo); // helloWorld

$bar = 'HELLO WORLD!';
$bar = lcfirst($bar); // hELLO WORLD!
$bar = lcfirst(strtoupper($bar)); // hELLO WORLD!
?>

相关文章

网友评论

      本文标题:用PHP将字符串php_content替换成Php Conten

      本文链接:https://www.haomeiwen.com/subject/wuisfxtx.html