between.php
Table of Contents
Functions
- between() : string
- Encapsulates an expression between specific characters.
Functions
between()
Encapsulates an expression between specific characters.
between([mixed $expression = null ][, string $left = '' ][, string|null $right = null ][, bool $flag = true ][, string $separator = ' ' ][, bool $trim = true ]) : string
Wraps the expression with $left
and $right
.
Handles arrays by joining their values with $separator
.
Leading/trailing $left
or $right
characters are trimmed to avoid duplication.
- If
$expression
is an array, its values are concatenated with$separator
. - If
$right
is null, it defaults to the value of$left
. - If
$flag
is false, no wrapping is applied.
Parameters
- $expression : mixed = null
-
The expression to encapsulate (string, array, or any type convertible to string).
- $left : string = ''
-
The left string to prepend.
- $right : string|null = null
-
The right string to append. Defaults to
$left
if null. - $flag : bool = true
-
Whether to apply the wrapping (default: true).
- $separator : string = ' '
-
Separator used when joining array values (default: space).
- $trim : bool = true
-
Whether to trim existing
$left
/$right
characters (default: true).
Tags
Return values
string —The wrapped expression if $flag
is true; otherwise the original expression as string.