title: php - create,dynamically, an array initialized with N null elements
body: <p>I want to create dynamically an array with N (without knowking N) elements. </p>
  
  <p>Something like a function </p>
  
  <pre><code>public function create_array($num_elements){
  
       .....
  }
  </code></pre>
  
  <p>that return me something like</p>
  
  <pre><code>//call the function.... 
  create_array(3);
  
  //and the output is: 
  array{
     0 =&gt; null
     1 =&gt; null
     2 =&gt; null
  }
  </code></pre>
  
  <p>I've already thought about <strong><code>array_fill</code></strong> and a simple <strong><code>foreach</code></strong> loop. </p>
  
  <p>Are there any other solutions? </p>