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

Popular posts from this blog

css - I want to align grid in center -

Contact Form PHP Email Script -

python - SWIG function not printing output -