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

2017-06-01  本文已影响6人  followyounger1

<?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!
?>

上一篇 下一篇

猜你喜欢

热点阅读