title: Unknown "usort() expects parameter 1 to be array, null given" error
body: <p>today im trying to sort array by passing a variable into its function. I can print and interact with the array just fine, but for some reason i cant pass it to a function.</p>
  
  <p>I've tried printing the array to see if it actually has any data and it turns out it has all the data i need.</p>
  
  <p>Here's where i initialize $filesinfo variable</p>
  
  <pre><code>&lt;?php
    $path = 'uploads/'.$file;
    $LastModified = filemtime($path);
    $filesize = filesize($path);
    $filextension = explode(".",$file);
    $filetp = end($filextension);
    $filesinfo[] = array($path, $LastModified, $filesize, $filetp);
    $size = filesize($path);
    $units = array( 'B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB');
    $power = $size &gt; 0 ? floor(log($size, 1024)) : 0;
    echo number_format($size / pow(1024, $power), 2, '.', ',') . ' ' . $units[$power]; ?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php echo date("F d Y H:i:s",filemtime("uploads/".$file));?&gt;&lt;/td&gt;
    &lt;td&gt;&lt;?php  $ext = explode(".",$file); echo end($ext);?&gt;&lt;/td&gt;
    &lt;td class="actions"&gt;&lt;?php echo '&lt;a class="btn btn-success" href="rename.php?name='.$file.'"&gt;Rename&lt;/a&gt;&lt;form action="main.php" method="POST"&gt; &lt;button class="btn btn-danger" type="submit" name="del" value="'.$file.'"&gt;Delete&lt;/button&gt;&lt;/form&gt;';?&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;?php
    }
  }
  ?&gt;
  &lt;?php endforeach; ?&gt;
  </code></pre>
  
  <p>And here's the place where i am trying to pass the $filesinfo to a function and it says that the parameter is null.</p>
  
  <pre><code>&lt;?php
  print_r($filesinfo);
  if ($_GET['sort']==="date" &amp;&amp; $_GET['type']==="desc") {
    SortByDate($filesinfo);
  }elseif($_GET['sort']=="date" &amp;&amp; $_GET['type']=="asc"){
    SortByDateAsc($filesinfo);
  }elseif($_GET['sort']=="name" &amp;&amp; $_GET['type']=="desc"){
    SortByNameDsc($filesinfo);
  }elseif($_GET['sort']=="name" &amp;&amp; $_GET['type']=="asc"){
    SortByNameAsc($filesinfo);
  }elseif($_GET['sort']=="size" &amp;&amp; $_GET['type']=="desc"){
    SortBySizeDsc($filesinfo);
  }elseif($_GET['sort']=="size" &amp;&amp; $_GET['type']=="asc"){
    SortBySizeAsc($filesinfo);
  }elseif($_GET['sort']=="type" &amp;&amp; $_GET['type']=="asc"){
    SortByTypeAsc($filesinfo);
  }elseif($_GET['sort']=="type" &amp;&amp; $_GET['type']=="desc"){
    SortByTypeDsc($filesinfo);
  }
  
  }
  </code></pre>
  
  <p>And here's one of my functions.</p>
  
  <pre><code>
  function SortByDate(&amp;$Files) {
  usort($Files, function($a, $b) {
  return $a['1'] &lt;=&gt; $b['1'];
  });
  }
  </code></pre>
  
  <p>All of these functions are almost identical they just change the way the content is sorted and returns values. But i still cant put $filesinfo as a parameter even when it is an array.</p>
  
  <p><strong>UPDATE : Sorry posted wrong function, here's the output from print</strong> </p>
  
  <pre><code>Array ( [0] =&gt; Array ( [0] =&gt; uploads/bootstrap-45c98b856dc045.zip [1] =&gt; 1553512534 [2] =&gt; 2705432 [3] =&gt; zip ) [1] =&gt; Array ( [0] =&gt; uploads/pointillist5c94d2e7eec5d.bmp [1] =&gt; 1553257191 [2] =&gt; 1080054 [3] =&gt; bmp ) [2] =&gt; Array ( [0] =&gt; uploads/sfdes.jpg [1] =&gt; 1553265149 [2] =&gt; 1246909 [3] =&gt; jpg ) [3] =&gt; Array ( [0] =&gt; uploads/ssser.sql [1] =&gt; 1553239646 [2] =&gt; 13098 [3] =&gt; sql ) [4] =&gt; Array ( [0] =&gt; uploads/vvv.jpg [1] =&gt; 1553263350 [2] =&gt; 879394 [3] =&gt; jpg ) [5] =&gt; Array ( [0] =&gt; uploads/wadaw.jpg [1] =&gt; 1553264937 [2] =&gt; 1246909 [3] =&gt; jpg ) [6] =&gt; Array ( [0] =&gt; uploads/wadawv.mp3 [1] =&gt; 1553263463 [2] =&gt; 4113874 [3] =&gt; mp3 ) ) 
  </code></pre>