You are here

function _transpose in Easychart 7.3

Same name and namespace in other branches
  1. 7.2 easychart.install \_transpose()
1 call to _transpose()
easychart_update_7200 in ./easychart.install
Transpose all existing data.

File

./easychart.install, line 190
Easychart install file.

Code

function _transpose($array) {
  $transposed_array = array();
  if ($array) {
    foreach ($array as $row_key => $row) {
      if (is_array($row) && !empty($row)) {

        //check to see if there is a second dimension
        foreach ($row as $column_key => $element) {
          $transposed_array[$column_key][$row_key] = $element;
        }
      }
      else {
        $transposed_array[0][$row_key] = $row;
      }
    }
    return $transposed_array;
  }
}