Oihana PHP

blockPrefix.php

Table of Contents

Functions

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

Functions

blockPrefix()

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

blockPrefix(array<string|int, mixed>|string $lines, string $prefix[, 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.

$prefix : string

Prefix to apply before 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 blockPrefix("a\n\nb", "// ", 2);
// Output:
//   // a
//   //
//   // b

echo blockPrefix(['a', '', 'b'], '-> ', '|');
// Output: -> a|-> |-> b

echo blockPrefix('', '>>>');
// Output: >>>
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

Formatted multi-line string.


        
On this page

Search results