Menu Samaritan's Purse

ARRAY_PAD

Pad array to the specified length with a value

SYNTAX

array_pad ( array $array , int $size , mixed $value ) : array

PARAMETERS

array

Initial array of values to pad.

size

New size of the array.

value

Value to pad if array is less than size.

RETURN

Returns a copy of the array padded to size specified by size with value value. If size is positive then the array is padded on the right, if it's negative then on the left. If the absolute value of size is less than or equal to the length of the array then no padding takes place.

EXAMPLES

RIGHT

Array
(
    [0] => 0
    [1] => 1
    [2] => pad
    [3] => pad
    [4] => pad
)

LEFT

Array
(
    [0] => pad
    [1] => pad
    [2] => pad
    [3] => 0
    [4] => 1
)

NONE

Array
(
    [0] => 0
    [1] => 1
)

PHP