将 space 分隔的字符串转换为 php 中的 class
Convert space seperated string to class in php
我有一个字符串'abc back'
在PHP
中有没有一种简单的方法可以将其转换成这样"AbcBack"
试试 ucwords
:
$input = 'abc back';
$output = str_replace(' ', '', ucwords($input));
在php.Use下面的代码中使用ucfirst()
函数
<?php
$string='abc back';
$p = explode($string," ");
$text="";
foreach($p as $m){
$text .= ucfirst($m);
}
echo str_replace(" ","",$text);// will print AbcBack
可以用ucwords()
来。使用下面的代码
<?php
$string='abc back';
echo str_replace(" ","",ucwords($string));
希望对您有所帮助
我有一个字符串'abc back'
在PHP
中有没有一种简单的方法可以将其转换成这样"AbcBack"
试试 ucwords
:
$input = 'abc back';
$output = str_replace(' ', '', ucwords($input));
在php.Use下面的代码中使用ucfirst()
函数
<?php
$string='abc back';
$p = explode($string," ");
$text="";
foreach($p as $m){
$text .= ucfirst($m);
}
echo str_replace(" ","",$text);// will print AbcBack
可以用ucwords()
来。使用下面的代码
<?php
$string='abc back';
echo str_replace(" ","",ucwords($string));
希望对您有所帮助