title: Create an array and arraypush
body: <p>I have a MySQL database where I retrieve an id and a web adress. All the webadresses have a simular structure: <code>www.aaa.com/main/sub/name</code></p>
  
  <p>I have a while loop that explodes the urls into <code>main</code>, <code>sub</code> and <code>name</code>, for each id I want to add the "id", "main", "sub" and "name" into an array, sort them, first on <code>main</code>, then <code>sub</code>, then <code>name</code>, so that I have:</p>
  
  <pre><code>Id Main   Sub          Name
  1  Ford   Transit      blue
  2  Ford   Transit      red
  3  Subaru Impreza      green
  4  Subaru whatever     blue
  </code></pre>
  
  <p>This is my code so far:</p>
  
  <pre><code>$total_array = array();
  $i=0;
  while ($i &lt; $num) {
      $id = mysql_result($result,$i,"id");
      $adress = mysql_result($result,$i,"address");
      $temp = explode("/", $adress);
      $car = temp[3];
      $make= temp[4];
      $color = temp[5];
      array_push($total_array,"$id","$car","$make","$color");
      $i++;
  }
  
  /* SOME ARRAY SORTING */
  
  print_r($total_array);
  </code></pre>
  
  <p>But I can't figure how to sort them, and I tried to get a name for each column, but I can't figure out how to do this.</p>