Easy Tutorial
❮ Func Array Unshift Php Imagealphablending ❯

PHP array_pad() Function

Complete PHP Array Reference Manual

Example

Return an array with 5 elements, inserting the value "blue" into the new elements:


Definition and Usage

The array_pad() function inserts a specified number of elements with a specified value into an array.

Tip: If you set the size parameter to a negative number, the function will insert new elements before the original array (see example below).

Note: If the size parameter is smaller than the length of the original array, the function will not remove any elements.


Syntax

Parameter Description
array Required. Specifies the array.
size Required. Specifies the number of elements in the array returned by the function.
value Required. Specifies the value of the new elements in the array returned by the function.

Technical Details

Return Value: Returns an array with the new elements.
PHP Version: 4+
--- ---

More Examples

Example 1

Using a negative size parameter:


❮ Func Array Unshift Php Imagealphablending ❯