문제

Using the following code, php explode at capital letters?

you can explode the string by uppercase. But how do you explode it only on the first uppercase? Say you have helloThereMister. I want to get hello ThereMister. I can concatenate the result from the link above, but if there is a way to skip it, then fantastic!

Thanks

도움이 되었습니까?

해결책

RTM my friend, as per documentation of preg_split you have also a $limit parameter so the answer is:

$pieces = preg_split('/(?=[A-Z])/', $str, 1);

다른 팁

look at manual for preg_split, third argument

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top