Transposes a bidimensional array (matrix)

@param array $array
@return array
971878
public function transpose($array)
    {
        $return = [];

        if (count($array)) {
            foreach ($array as $key => $values) {
                foreach ($values as $subkey => $value) {
                    $return[$subkey][$key] = $value;
                }
            }
        }

        return $return;
    }
680481
public static function convertStringToValueArray(array $array): array
    {

        foreach ($array as $i => $attr)
            $array[$i] = (is_array($attr) ? self::convertStringToValueArray($attr) : self::convertStringToValues($attr));

        return $array;
    }
423995
public static function array_pick($array) {
    if (!is_array( $array )) {
      return $array;
    }
    $keys = array_slice(func_get_args(), 1);
    $keys = self::array_flatten($keys);
    $pick = array();
    foreach ( $keys as $key ) {
      if (!array_key_exists($key, $array)) {
        continue;
      }
      $pick[$key] = $array[$key];
    }
    return $pick;
  }
1243228
public function getColumnNamesFromAttributes($array)
    {
        if (!empty($this->mappings)) {
            $newArray = [];
            $flipped = array_flip($this->mappings);
            foreach ($array as $key => $value) {
                $attributeName = isset($flipped[$key]) ? $flipped[$key] : $key;
                $newArray[$attributeName] = $value;
            }

            return $newArray;
        }

        return $array;
    }
1100568
public static function flatten($array)
    {
        $return = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $return = \array_merge($return, static::flatten($value));
            } elseif ($value instanceof Collection) {
                $return = \array_merge($return, static::flatten($value->all()));
            } else {
                $return[$key] = $value;
            }
        }

        return $return;
    }
1047886
protected function _convertArrayable(array $array)
    {
        $arr = [];

        foreach ($array as $key => $value) {
            if ($value instanceof ArrayableInterface) {
                $arr[$value instanceof NameableInterface ? $value->getName() : $key] = $value->toArray();
            } elseif (\is_array($value)) {
                $arr[$key] = $this->_convertArrayable($value);
            } else {
                $arr[$key] = $value;
            }
        }

        return $arr;
    }
523541
private function arrayCopy(array $array) {
    $result = array();
    foreach ($array as $key => $val) {
      if (is_array($val)) {
        $result[$key] = self::arrayCopy($val);
      }
      elseif (is_object($val)) {
        $result[$key] = clone $val;
      }
      else {
        $result[$key] = $val;
      }
    }
    return $result;
  }
260691
public function arrayToHash($array)
    {
        $hash = [];
        for ($i = 0, $s = sizeof($array) - 1; $i < $s; ++$i) {
            $hash[$array[$i]] = $array[++$i];
        }
        return $hash;
    }
179047
public static function ArrayAsObject($Array) {
      if (!is_array($Array))
         return $Array;

      $Return = new stdClass();
      foreach($Array as $Property => $Value) {
         $Return->$Property = $Value;
      }
      return $Return;
   }
896205
public static function convertArrayToFlatTextArray(array $array) {
    $rows = [];
    $max_line_length = 60;
    foreach ($array as $key => $value) {
      if (is_array($value)) {
        $flattened_array = self::flattenToDotNotatedKeys($value);
        foreach ($flattened_array as $sub_key => $sub_value) {
          if ($sub_value === TRUE) {
            $sub_value = 'true';
          }
          elseif ($sub_value === FALSE) {
            $sub_value = 'false';
          }
          $rows[] = [
            "$key.$sub_key",
            wordwrap($sub_value, $max_line_length, "\n", TRUE),
          ];
        }
      }
      else {
        if ($value === TRUE) {
          $contents = 'true';
        }
        elseif ($value === FALSE) {
          $contents = 'false';
        }
        else {
          $contents = wordwrap($value, $max_line_length, "\n", TRUE);
        }
        $rows[] = [$key, $contents];
      }
    }

    return $rows;
  }
853754
public function reverseTransform($array)
    {
        if (is_array($array) && array_key_exists(0, $array)) {
            $newIds = [];
            $ids = explode(',', $array[0]);
            $repo = $this->em->getRepository('VictoireBlogBundle:Tag');

            $objects = $repo->findById($ids);
            foreach ($objects as $object) {
                if (false !== $key = array_search($object->getId(), $ids)) {
                    $newIds[] = $ids[$key];
                    unset($ids[$key]);
                }
            }

            $objectsArray = [];
            foreach ($ids as $title) {
                if ($title !== '') {
                    $object = new Tag();
                    $object->setTitle($title);
                    $this->em->persist($object);
                    $objectsArray[] = $object;
                }
            }
            $this->em->flush();

            foreach ($objectsArray as $objectObj) {
                $newIds[] = $objectObj->getId();
            }

            return $newIds;
        }

        return $array;
    }
880218
public function flattenArray($array)
    {
        $result = [];
        foreach (array_dot($array) as $key => $value) {
            $splitKey = explode('.', $key);
            $newKey = $this->createArrayKey($splitKey);
            $result = array_merge($result, [$newKey => $value]);
        }

        return $result;
    }
232415
private function _flatten($array)
    {
        if (!is_array($array)) {
            // nothing to do if it's not an array
            return array($array);
        }
        $result = array();
        foreach ($array as $value) {
            // explode the sub-array, and add the parts
            $result = array_merge($result, $this->_flatten($value));
        }
        return $result;
    }
491826
private function flattenArray($array)
    {
        $objTmp = (object)['aFlat' => []];

        array_walk_recursive($array, function(&$v, $k, &$t) {
            $t->aFlat[] = $v;
        }, $objTmp);

        return $objTmp->aFlat;
    }
1035574
public static function typeCast(array $array)
    {
        $return = [];
        
        foreach ($array as $k => $v) {
            if (is_numeric($v)) {
                $return[$k] = StringHelper::typeCastNumeric($v);
            } elseif (is_array($v)) {
                $return[$k] = self::typeCast($v);
            } else {
                $return[$k] = $v;
            }
        }
        
        return $return;
    }
157566
public static function flatten(array $array)
    {
        $out = [];

        foreach (new RecursiveIteratorIterator(new RecursiveArrayIterator($array)) as $key => $item) {
            if (is_int($key)) {
                $out[] = $item;
            } else {
                $out[$key] = $item;
            }
        }

        return $out;
    }
138361
public function flatten(array $array)
    {
        $tmp = array();
        foreach ($array as $a) {
            if (is_array($a)) {
                $tmp = array_merge($tmp, array_flat($a));
            } else {
                $tmp[] = $a;
            }
        }

        return $tmp;
    }