Oihana PHP

kebab.php

Table of Contents

Functions

kebab()  : string
Converts a camelCase or PascalCase string into kebab-case (lowercase with hyphens).

Functions

kebab()

Converts a camelCase or PascalCase string into kebab-case (lowercase with hyphens).

kebab(string|null $source) : string

Internally uses the snake() function with - as the separator. Useful for URL slugs, CSS class names, or readable identifiers.

If the input is null or empty, an empty string is returned.

Parameters
$source : string|null

The input string to transform.

Tags
example
echo kebab("helloWorld");      // Outputs: "hello-world"
echo kebab("HelloWorld");      // Outputs: "hello-world"
echo kebab("XMLHttpRequest");  // Outputs: "xml-http-request"
echo kebab(null);              // Outputs: ""
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The kebab-case representation of the input.


        
On this page

Search results