Oihana PHP

betweenBraces.php

Table of Contents

Functions

betweenBraces()  : string
Encapsulates an expression between braces '{..}'

Functions

betweenBraces()

Encapsulates an expression between braces '{..}'

betweenBraces([mixed $expression = '' ][, bool $useBraces = true ][, string $separator = ' ' ][, bool $trim = true ]) : string
  • If the expression is a string, it is wrapped in braces.
  • If the expression is an array, its values are concatenated with the given separator, then wrapped in braces.
  • If $useParentheses is false, the expression is returned without wrapping.
Parameters
$expression : mixed = ''

The expression to wrap.

$useBraces : bool = true

Whether to apply the braces.

$separator : string = ' '

Separator for arrays.

$trim : bool = true

Whether to trim existing $left/$right characters (default: true).

Tags
example
betweenBraces('id: 1');           // '{ id: 1 }'
betweenBraces(['x', 'y']);        // '{ x y }'
betweenBraces(['x', 'y'], false); // 'x y'
author

Marc Alcaraz

since
1.0.6
Return values
string

The wrapped expression.


        
On this page

Search results