a::fill($array, $limit, $fill = 'placeholder')

Fills an array up with additional elements to certain amount.

  • $array (array)
    The source array
  • $limit (int)
    The number of elements the array should contain after filling it up.
  • $fill (mixed)
    The element, which should be used to fill the array
  • return (array)
    The filled-up result array

Example

<?php
$array = array(
   'cat',
   'dog',
   'bird',
);

$result = a::fill($array, 5, 'elephant');

var_dump($result);

Result:

array (size=5)
  0 => string 'cat' (length=3)
  1 => string 'dog' (length=3)
  2 => string 'bird' (length=4)
  3 => string 'elephant' (length=8)
  4 => string 'elephant' (length=8)