PHP array_pad() function with example

 04 - Mar - 2022
 XpertPhp
 44

In this article, We will explain to you PHP array_pad() function with example.

PHP array_pad() function

The array_pad() function is a built-in function of PHP. which is used to inserts a specified number of items with a specified value into an array and returns an array with new elements. so you can see our PHP array Function example. Syntax

array_pad(array, size, value);

Example

<?PHP
$arr=array("jay","raj");
print_r(array_pad($arr,4,"deep"));
?>

Output

Array
(
    [0] => jay
    [1] => raj
    [2] => deep
    [3] => deep
)