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

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

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

google shop client API returns 400 bad request error while adding an item -