key.php
Table of Contents
Functions
- key() : string
- Returns a transformed key by optionally prepending a prefix.
Functions
key()
Returns a transformed key by optionally prepending a prefix.
key(null|string|array<string|int, mixed> $key[, string|null $prefix = '' ][, string $separator = '.' ]) : string
This function allows you to prefix a key string with another string, separated by a custom separator. If the prefix is empty or null, the original key is returned unchanged.
Parameters
- $key : null|string|array<string|int, mixed>
-
The key to transform :
nullreturns an empty stringstringis used directlyarrayis joined using the$separator
- $prefix : string|null = ''
-
Optional prefix to prepend. Default is an empty string. If
nullor empty, the prefix is ignored. - $separator : string = '.'
-
The separator used both to join array keys and to separate the prefix from the key.
Tags
Return values
string —The transformed key.
Returns an empty string if $key is null.
Returns "{$prefix}{$separator}{$key}" when a prefix is provided,
otherwise returns the normalized key.