php - Initialize array with specific amount of elements? -
is possible initialize array specific amount of elements, without loop?
// pseudo code $reviews = array(5); print_r($reviews); // outputs 5 empty elements in array array ( [0] => [1] => [2] => [3] => [4] => )
several ways, here's three:
$array = array_fill(0, 5, ''); $array[]=$array[]=$array[]=$array[]=$array[]=''; $array = explode(' ', ' ');
Comments
Post a Comment