Showing posts with label Explode At Capital Letters. Show all posts
Showing posts with label Explode At Capital Letters. Show all posts

Thursday, May 11, 2017

PHP explode at capital letters

<?php
$str = "ExplodeAtCapitalLetters";
$str[0] = strtolower($str[0]);
$pieces = preg_split('/(?=[A-Z])/',$str);
$pieces[0][0] = strtoupper($pieces[0][0]);
print_r($pieces);



Array
(
    [0] => Explode
    [1] => At
    [2] => Capital
    [3] => Letters
)