HTML tutorial
CSS3 tutorial
Bootstrap tutorial
JavaScript tutorial
JQuery tutorial
AngularJS tutorial
React tutorial
NodeJS tutorial
PHP tutorial
Python tutorial
Python3 tutorial
Django tutorial
Linux tutorial
Docker tutorial
Ruby tutorial
Java tutorial
C tutorial
C ++ tutorial
Perl tutorial
JSP tutorial
Lua tutorial
Scala tutorial
Go tutorial
ASP.NET tutorial
C # tutorial
PHP Array Reference : Return 5 elements and insert a value of "blue" to the new elements in the array
The array_pad() function inserts a specified number of elements, with a specified value, to an 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 |
Return Value: | Returns an array with new elements |
---|---|
PHP Version: | 4+ |
Using a negative size parameter:
<?php
$a=array("red","green");
print_r(array_pad($a,-5,"blue"));
?>
❮ PHP Array Reference