Oihana PHP

blockSuffix.php

Table of Contents

Functions

blockSuffix()  : string
Suffix and indent each line of a multi-line string or array of lines.

Functions

blockSuffix()

Suffix and indent each line of a multi-line string or array of lines.

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

Array of lines or multi-line string.

$suffix : string

Suffix to append to each line.

$indent : string|int = ''

Indentation (string or number of spaces).

$separator : string = PHP_EOL

Line separator (default: PHP_EOL).

$keepEmptyLines : bool = true

Whether to keep empty lines (default: true).

Tags
example
echo blockSuffix("a\n\nb", " //", 2);
// Output:
//   a //
//   //
//   b //

echo blockSuffix(['a', '', 'b'], ' <-', '|');
// Output: a <-| <-|b <-

echo blockSuffix('', '<<<');
// Output: <<<
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

Formatted multi-line string.


        
On this page

Search results