upcase split

    0

    1

    jvitstring
    JVIT PHP
    var_dump(ucsplit('MyString'));
    // array(2) {
    //   [0]=>
    //   string(2) "My"
    //   [1]=>
    //   string(6) "String"
    // }
    

    Shortcut: split

    /**
    * Split a string into pieces by uppercase characters.
    *
    * @param  string  $string
    * @return array
    */
    function ucsplit($string)
    {
      return preg_split('/(?=\p{Lu})/u', $string, -1, PREG_SPLIT_NO_EMPTY);
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.