PHP Programing language

adplus-dvertising
array_pad() Function in PHP
Previous Home Next

array_pad()

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

Syntax:
array_pad(array,size,value)

In above syntax,"array" specifies an array, "size" specifies the number of elements in the array returned from the function and "value" specifies the value of the new elements in the array returned from the function

Example:

<?php
$a=array("Apple","Mango");
print_r(array_pad($a,5,"Orange"));
?>

Output:

Array ( [0] => Apple [1] => Mango [2] => Orange [3] => Orange [4] => Orange )

Previous Home Next