$arr = array('1st', '1st');
The above $arr has 2 items , I want to repeat $arr so that it's populated with 4 items
Is there a single call in PHP?
$arr = array('1st', '1st');
The above $arr has 2 items , I want to repeat $arr so that it's populated with 4 items
Is there a single call in PHP?
array_fill function should help:
array array_fill ( int $start_index, int $num, mixed $value )
Fills an array with num entries of the value of the value parameter, keys starting at the start_index parameter.
In your case code will look like:
$arr = array_fill(0, 4, '1st');