static public fill ( array $array, integer $limit, mixed $fill = 'placeholder' ) : array | ||
$array | array | The source array |
$limit | integer | 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 |
static function fill($array, $limit, $fill = 'placeholder')
{
if (count($array) < $limit) {
$diff = $limit - count($array);
for ($x = 0; $x < $diff; $x++) {
$array[] = $fill;
}
}
return $array;
}
public function testFill() { $users = $this->users; $users = a::fill($users, 100); $this->assertEquals(100, count($users)); }