Add new values to the beginning of the array by using a negative value for $size: : array_pad « Data Structure « PHP






Add new values to the beginning of the array by using a negative value for $size:

 
<?php 
$birds = array('a', 'b', 'c', 'd'); 

$more_birds = array_pad($birds, -6, 'some bird'); 

printf("%s", var_export($more_birds, TRUE)); 
?>
  
  








Related examples in the same category

1.An array that is padded from the front
2.Setting an Array's Size: array array_pad(array $input, int $size, mixed $value)
3.Using array_pad() with associative arrays
4.array_pad 1
5.array_pad 2
6.array_pad 3
7.array_pad() function expands an array to a precise size, padding it with a default value.
8.Pad array to the specified length with a value