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

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -