convert to camel case

    0

    7

    jvitstringcamel
    JVIT PHP

    echo convertToCamelCase("studlyCase String"); result: StudlyCaseString

    Shortcut: camel

    /**
    * Convert a value to studly caps case.
    *
    *
    * @param  string  $value
    * @return string StudlyCaseString
    */
    function convertToStudlyCase($value)
    {
      $words = explode(' ', str_replace(['-', '_'], ' ', $value));
    
      $studlyWords = array_map(function ($word) {
        return ucfirst($word);
      }, $words);
    
      return implode($studlyWords);
    }
    
    /**
    * Convert a value to camel case.
    *
    * @param  string  $value
    * @return string
    */
    function convertToCamelCase($value)
    {
      return lcfirst(convertToStudlyCase($value));
    }
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.