Oihana PHP

prepend.php

Table of Contents

Functions

prepend()  : string
Prepend one or more prefix strings to the given source string, then normalize the result.

Functions

prepend()

Prepend one or more prefix strings to the given source string, then normalize the result.

prepend(string|null $source, string ...$prefix) : string

If the source string is null, returns an empty string. If multiple prefixes are provided, they are concatenated before prepending. The resulting string is normalized using Unicode Normalization Form C (NFC).

Parameters
$source : string|null

The original string or null.

$prefix : string

One or more prefix strings to prepend.

Tags
throws
InvalidArgumentException

If the resulting string is invalid UTF-8 or cannot be normalized.

example
use function oihana\core\strings\prepend;

echo prepend( 'world', 'hello', ' ' ); // Outputs: "hello world"
echo prepend( null, 'foo');             // Outputs: "foo"
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

The normalized concatenation of prefix(es) and source.


        
On this page

Search results