I want to create an array like this [1, 1, 1, 1, 1]
[1, 1, 1, 1, 1]
In python, I can use myarray = [1]*5
myarray = [1]*5
Is there an equivalent method in PHP or do I need to add all the elements of the loop.
http://php.net/manual/en/function.array-fill.php
<?php var_dump( array_fill( 0, 5, 1 ) ); ?>
what you need is array_fill
see php array_fill