Home >php教程 >php手册 >php 将字符串按大写字母分隔成字符串数组

php 将字符串按大写字母分隔成字符串数组

WBOY
WBOYOriginal
2016-06-06 20:33:331771browse

php 将字符串按大写字母分隔成字符串数组,需要的朋友可以参考下。

alert("createTechBook".split(/(?=[A-Z])/)) 谢了啊
代码如下:
$str="abcDefGhi";
/*
preg_match_all("/([a-zA-Z]{1}[a-z]*)?[^A-Z]/",$str,$array);
*/
$array=preg_split("/(?=[A-Z])/",$str);
print_r($array);
?>


代码如下:
$string = "createTechBook";
$arr = preg_split("/(?=[A-Z])/", $string);
print_r($arr);
?>

也可以
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