Oihana PHP

pascal.php

Table of Contents

Functions

pascal()  : string
Converts a string to PascalCase (a.k.a. UpperCamelCase).

Functions

pascal()

Converts a string to PascalCase (a.k.a. UpperCamelCase).

pascal(string|null $source[, array<int, string> $separators = ["_", "-", "/"] ]) : string

Builds on camel() and then upper-cases the first character via ucFirst(). Returns an empty string when the source is null or empty.

Parameters
$source : string|null

The input string to convert.

$separators : array<int, string> = ["_", "-", "/"]

Separator characters split into words before conversion. Defaults to ["_", "-", "/"].

Tags
example
use function oihana\core\strings\pascal;

echo pascal( 'hello_world' ) ; // "HelloWorld"
echo pascal( 'foo-bar_baz' ) ; // "FooBarBaz"
echo pascal( 'user/name' )   ; // "UserName"
author

Marc Alcaraz (ekameleon)

since
1.0.9
Return values
string

The PascalCase representation of the input string.

On this page

Search results