I have strings like:
$a = 'helloMister'; $b = 'doggyWaltz'; $c = 'bumWipe'; $d = 'pinkNips';   How can I explode at the capital letters? I have search on google for some time and came back with nothing!
The explode() function breaks a string into an array. Note: The "separator" parameter cannot be an empty string. Note: This function is binary-safe.
The strtoupper() function converts a string to uppercase. Note: This function is binary-safe. Related functions: strtolower() - converts a string to lowercase.
If you want to split helloMister into hello and Mister you can use preg_split to split the string at a point just before the uppercase letter by using positive lookahead assertion:
$pieces = preg_split('/(?=[A-Z])/',$str);   and if you want to split it as hello and ister you can do:
$pieces = preg_split('/[A-Z]/',$str); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With