Is there any method (that doesn't use loop or recursion) to create and fill an array with values?
To be precise, I want to have an effect of
$t = array();
for($i = 0; $i < $n; $i++){
$t[] = "val";
}
But simpler.
use array_fill()
:
$t = array_fill(0, $n, 'val');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With