Convert strings with underscores into CamelCase.

@param $string
@param bool $firstCharCaps

@return mixed
339467
private function underscoreToCamelCase($string, $firstCharCaps = false)
    {
        if ($firstCharCaps == true) {
            $string[0] = strtoupper($string[0]);
        }

        $func = create_function('$c', 'return strtoupper($c[1]);');

        return preg_replace_callback('/_([a-z])/', $func, $string);
    }
800043
public static function ucfirst(string $string): string
    {
        return self::strtoupper(self::substr($string, 0, 1)) . self::substr($string, 1);
    }
687600
public static function camelCase(string $string, array $noStrip = null, bool $lowerCaseFirstLetter = null)
    {
        // non-alpha and non-numeric characters become spaces
        $string = preg_replace('/[^a-z0-9' . implode('', $noStrip ?? []) . ']+/i', ' ', $string);
        $string = trim($string);
        $string = ucwords($string);
        $string = str_replace(' ', '', $string);

        if ($lowerCaseFirstLetter === null || $lowerCaseFirstLetter === true) {
            $string = lcfirst($string);
        }

        return $string;
    }
1126692
static function CamelCase($string) {
		$string = preg_replace_callback('#([_])(\w)#', function ($m) {
			return strtoupper($m[2]);
		}, strtolower($string));

		return ucfirst($string);
	}
208992
public static function firstSpace($string) {
		$firstSpace = strpos($string, " ");
		return ($firstSpace === false)? strlen($string) : $firstSpace;
	}
1149417
public static function ucFirst($str)
    {
        if (self::$use_mbstring) {
            $first = self::toUpper(self::sub($str, 0, 1));
            $str   = $first . self::sub($str, 1);
        } else {
            $str   = ucfirst($str);
        }
        
        return $str;
    }
30271
public static function spaceToCamelCase($string, $type = '_', $first_char_caps = false)
    {
        if($first_char_caps === true)
        {
            $string[0] = strtoupper($string[0]);
        }

        $func = create_function('$c', 'return strtoupper($c[1]);');

        return preg_replace_callback('/' . $type . '([a-z])/', $func, $string);
    }
863480
public static function tableName($string) {
        return static::cache(array(__METHOD__, $string), function() use ($string) {
            return lcfirst(Inflector::camelCase(Inflector::pluralize($string)));
        });
    }
488944
public function bumpyCase($string)
    {
        $words = explode('_', $string);
        foreach ($words as &$word) {
            $word = ucfirst($word);
        }
        unset ($word);
        
        $camelCase = implode('', $words);
        return $camelCase;
    }
525090
public static function camelize($word, $uppercaseFirstLetter = true)
    {
        $word = self::underscore($word);
        $word = str_replace(' ', '', ucwords(str_replace('_', ' ', $word)));

        if ($uppercaseFirstLetter === false) {
            $word = lcfirst($word);
        }

        return $word;
    }
927949
public static function ucFirst($string)
    {
        $ucFirst = static::sub($string, 0, 1);
        $ucFirst = static::upp($ucFirst);

        return $ucFirst . static::sub($string, 1);
    }
233295
public static function camelCase($value, $firstLower = false)
  {
      $value = preg_replace('/[^a-zA-Z0-9\s]/', ' ', $value);
      $value = lcfirst($value);
      $values = static::split(' ', $value);
      for ($i = 1; $i < count($values); ++$i) {
          $values[$i] = ucfirst($values[$i]);
      }

      return implode('', $values);

    // $val = str_replace(' ', '', ucwords(str_replace('_', ' ', $value)));
    // if ($firstLower) $val = strtolower(substr($val,0,1)).substr($val,1);
    // return $val;
  }
1089767
public static function string_to_camelcase( $string, $capitalize = true ){
  	$normalize_string = str_replace( array( '-', '_' ), ' ', $string );
  	$ucwords = ucwords( $normalize_string, ' ' );
  	$camelcase_string = str_replace(' ', '', $ucwords);
    if( ! $capitalize ) {
    	$camelcase_string = lcfirst( $camelcase_string );
    }
    return $camelcase_string;
  }
277161
protected function changeCase($string)
    {
        if ($this->isLowercase()) {
            return strtolower($string);
        }

        if ($this->isUppercase()) {
            return strtoupper($string);
        }

        return $string;
    }
1053636
protected function snakeToCamelCase($string, $smallFirst = false)
    {
        $parts = explode('_', $string);

        array_walk($parts, function(&$element) {
           $element = ucfirst($element);
        });

        $result = implode('', $parts);

        return $smallFirst ? lcfirst($result) : $result;
    }
1044360
public static function camelcaseToSnakecase(string $string): string
    {
        preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $string, $matches);

        $words = $matches[0];
        foreach ($words as &$word) {
            $word = ($word == strtoupper($word))
                ? strtolower($word)
                : lcfirst($word);
        }

        return implode('_', $words);
    }
1033362
function ucfirst( $str ) {
		$o = ord( $str );
		if ( $o < 96 ) { // if already uppercase...
			return $str;
		} elseif ( $o < 128 ) {
			return ucfirst( $str ); // use PHP's ucfirst()
		} else {
			// fall back to more complex logic in case of multibyte strings
			return $this->uc( $str, true );
		}
	}