betweenSpaces.php
Table of Contents
Functions
- betweenSpaces() : string
- Wraps an expression with spaces on both sides.
Functions
betweenSpaces()
Wraps an expression with spaces on both sides.
betweenSpaces([mixed $expression = '' ][, bool $useSpaces = true ][, string $separator = ' ' ][, bool $trim = true ]) : string
Calls between()
with space characters as $left
and $right
. Handles strings, arrays, and optional suppression of spaces.
- String: Simply prepends and appends a space.
- Array: Concatenates array values using the specified
$separator
, then wraps the resulting string in spaces. - Other types: Converted to string before wrapping.
- If
$useSpaces
isfalse
, the expression is returned as-is without any surrounding spaces.
Parameters
- $expression : mixed = ''
-
The value to wrap. Can be string, array, or any type convertible to string.
- $useSpaces : bool = true
-
Whether to apply the surrounding spaces (default:
true
). - $separator : string = ' '
-
Separator to use when
$expression
is an array (default:' '
). - $trim : bool = true
-
Whether to trim existing
$left
/$right
characters (default: true).
Tags
Return values
string —The wrapped expression with spaces if $useSpaces
is true; otherwise the original expression as string.