array_pad

array array_pad(array array, int pad_size, mixed pad_value) 
array Array to pad
pad_size Number of elements in resulting array
pad_value Value to give to added elements

Pads an array with a specified number of elements with a given value.

Returns:

Original array, possibly padded to a greater number of elements; NULL on failure

Description:

This function pads the array passed in array with elements having the value given in pad_value until it contains the number of elements given by the absolute value of pad_size . If pad_size is positive, the new elements are added to the end of array . If pad_size is negative, the new elements are added to the beginning. If the absolute value of pad_size is equal to or less than the number of ...

Get PHP Functions Essential Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.