Oihana PHP

block.php

Table of Contents

Functions

block()  : string
Format an indented multi-line text block.

Functions

block()

Format an indented multi-line text block.

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

Lines as array or multi-line string.

$indent : string|int = ''

Indentation as string or number of spaces.

$separator : string = PHP_EOL

Line separator (defaults to PHP_EOL).

$keepEmptyLines : bool = true

Whether to preserve empty lines (default: true).

Tags
example

Use an input array :

echo block
([
    'if ($host ~* ^example\\.com$)',
    '{',
    '    rewrite ^(.*) https://www.example.com$1 permanent;',
    '    break',
    '}'
] , 4 ) ;

echo block(['a', 'b', 'c'], '-', 0); // "a-b-c"

Use an input string:

echo blockLines( "foo\nbar", '-> ' ) ;
// Output:
// -> foo
// -> bar
author

Marc Alcaraz (ekameleon)

since
1.0.0
Return values
string

A single string with the lines joined by $separator and indented.


        
On this page

Search results