Oihana PHP

wrapBlock.php

Table of Contents

Functions

wrapBlock()  : string
Wraps a block of lines with a header and footer line.

Functions

wrapBlock()

Wraps a block of lines with a header and footer line.

wrapBlock(array<string|int, mixed>|string $lines, string $before, string $after[, string|int $indent = '' ][, string $separator = PHP_EOL ][, bool $keepEmptyLines = true ]) : string
Parameters
$lines : array<string|int, mixed>|string

Array or string of lines to wrap.

$before : string

Line inserted before the block.

$after : string

Line inserted after the block.

$indent : string|int = ''

Indentation for the inner block (default: '').

$separator : string = PHP_EOL

Line separator (defaults to PHP_EOL).

$keepEmptyLines : bool = true

Whether to preserve empty lines (default: true).

Tags
example
echo wrapBlock("line1\nline2", '{', '}', 4);
// Output:
// {
//     line1
//     line2
// }
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

Final wrapped block.


        
On this page

Search results