PHP array_pad() Function

The array_pad() function is used to padding (insert) a specified number of elements, with a specified value, into an array.

Tip: If you assign a negative size parameter, the function will insert new elements BEFORE the original elements (See example below).

Note: This function will not delete any elements if the size parameter is less than the size of the original array.

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




$array1 = array("Cooper","Samuel");


Array ( [0] => James [1] => James [2] => James [3] => James [4] => Cooper [5] => Samuel ) 

Leave a Reply

Your email address will not be published. Required fields are marked *