convert camel to underscore

    0

    0

    jvit
    JVIT PHP
    camelCaseHeheHihiTestOK
    => 
    camel_case_hehe_hihi_test_ok
    
    

    Shortcut: string.camelToUnderScore

    /**
    * Converts a camel cased string to a snake cased string.
    */
    function convertCamelCaseToUnderscore(string $string): string
    {
      return mb_strtolower(preg_replace('/(?<!^)((?=[\p{Lu}][^\p{Lu}])|(?<![\p{Lu}])(?=[\p{Lu}]))/', '_', $string));
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.