title: Transpose an Array in php
body: <p>I am trying to transpose the array,
  Here is my current code: I apologise if it looks like I am completely stupid, but I am relatively new to php and programming in general, so this task has been very difficult!!
  Thank you so much in advance.</p>
  
  <pre><code>$store1 = file("1.txt");
  $store1 = array();
   $file1 = fopen("1.txt", "r") or die("Unable to open file!");   
  
  //put the .txt file into an array
  while (!feof($file1))
  {
  $line=fgets($file1);
  
  //process line however you like
  $line=trim($line);
  
  //add to array
  $store1[]=$line;
  
  }
  
  ///trying to transpose matrix the array in this function..
   function transposeArray($store1)
  {
  if(is_object($store1))
      $store1 = get_object_vars($store1);
  
  if(!is_array($store1))
      return $store1;
  
  $new_data = array();
  //var_dump($data);
  foreach ($store1 as $key=&gt;$record);
      foreach ($record as $index=&gt;$value);
          $new_data[$index][$key] = $value;
      //var_dump($new_data);
      return $new_data;
  echo $new_data[1];
  }
  
  //trying to call the function..
     transposeArray($store1);
  
  fclose($file1);
  </code></pre>