Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. GPBUtil.php

function camel2underscore

1 call to camel2underscore()
GPBUtil::parseFieldMask in vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php

File

vendor/google/protobuf/src/Google/Protobuf/Internal/GPBUtil.php, line 19

Namespace

Google\Protobuf\Internal

Code

function camel2underscore($input) {
    preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
    $ret = $matches[0];
    foreach ($ret as &$match) {
        $match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
    }
    return implode('_', $ret);
}
RSS feed
Powered by Drupal