Home > Backend Development > PHP Tutorial > php 将字符串按大写字母分隔成字符串数组_php技巧

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

WBOY
Release: 2016-05-17 09:26:10
Original
938 people have browsed it

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);
?>

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