returns all the unique values for columns (fields)

@param array        $array     array
@param array|string $colsToGet columns desired
@param boolean      $assoc     when only returning one col, should each row be an assoc/hash array?

@return array
506737
public static function uniqueCol($array, $colsToGet, $assoc = true)
    {
        if (!\is_array($array)) {
            $array = array();
        }
        if (!\is_array($colsToGet)) {
            $colsToGet = array($colsToGet);
        }
        $colValuesTemp    = array();
        $colValuesStrings = array();
        $colValues = array();
        foreach (\array_keys($array) as $i) {
            $lineValues = array();
            foreach ($colsToGet as $colname) {
                if (isset($array[$i][$colname])) {
                    $lineValues[$colname] = $array[$i][$colname];
                }
            }
            if (!empty($lineValues)) {
                $lineString = \implode('', \array_values($lineValues));
                \array_push($colValuesTemp, $lineValues);
                \array_push($colValuesStrings, $lineString);
            }
        }
        $keys = \array_keys(\array_unique($colValuesStrings));      // $keys are the line-#s
        foreach ($keys as $key) {
            \array_push($colValues, $colValuesTemp[$key]);
        }
        if (\count($colsToGet) == 1) {
            \sort($colValues);
            if (!$assoc) {
                foreach ($colValues as $i => $a) {
                    $colValues[$i] = $a[ $colsToGet[0] ];
                }
            }
        } else {
            $colValues = self::fieldSort($colValues, $colsToGet);
        }
        return $colValues;
    }
1295212
public function getArrayValue(array $array, string $key)
    {
        foreach ($this->getBoth($key) as $loopKey) {
            if (array_key_exists($loopKey, $array)) {
                return $array[$loopKey];
            }
        }
    }
656128
public static function getArray(array $array, $associative = true)
    {
        $arrayText = "[";
        $index     = 0;
        $count     = count($array);
        foreach ($array as $key => $value) {
            if ($associative) {
                $arrayText .= static::getValue($key);
                $arrayText .= " => ";
            }
            $arrayText .= static::getValue($value);
            if ($index < $count - 1) {
                $arrayText .= ", ";
                $index++;
            }
        }
        return $arrayText . "]";
    }
1207632
function GetAssoc($force_array = false, $first2cols = false)
	{
		$records = $this->_numOfRows;
		$results = array();
		for ( $i=0; $i < $records; $i++ ) {
			foreach ( $this->fields as $k=>$v ) {
				if ( is_array( $v ) ) {
					if ( $v['count'] == 1 ) {
						$results[$i][$k] = $v[0];
					} else {
						array_shift( $v );
						$results[$i][$k] = $v;
					}
				}
			}
		}

		return $results;
	}
965015
public function getColumns()
    {
        $columns = array();
        foreach ($this->getRows() as $row) {
            $columns = array_merge($columns, $row->getColumns());
        }
        return array_unique($columns);
    }
1036926
public static function arrayColumns(array $data)
    {
        // Count the amount of values from the source input
        $count = count($data);

        if ($count === 0) {
            return false;
        }

        if ($count === 1) {
            return array_keys($data[0]);
        }

        if (isset($data[0])) {
            return array_keys($data[0]);
        } else {
            return false;
        }
    }
262693
public function selectManager($sql, $array = array(), $fetchMode = \PDO::FETCH_ASSOC)
     {
         $stmt = $this->conn->prepare($sql);

         foreach ($array as $key => $values) {
             $stmt->bindValue("$key", $values);
         }
         $stmt->execute();

         do {
             return $stmt->fetchAll($fetchMode);
         } while (
            $stmt->nextRowset());
     }
13972
public function unique($columns, $name = null, $algorithm = null)
    {
        return $this->indexCommand('unique', $columns, $name, $algorithm);
    }
1006725
public static function getNextKey($key, array $array) {
		$keys = array_keys($array);
		$found_index = array_search($key, $keys);
		if($found_index === false || $found_index + 1 === count($keys))
			return false;
		return $keys[$found_index + 1];
	}
456640
public function groupBy($array, $columns)
    {
        // ensure $columns parameter is array
        $columns = (array) $columns;

        // get first group-by column
        $col = array_shift($columns);

        $result = array();
        foreach ($array as $row) {
            $key = (string) is_object($row) ? $row->$col : $row[$col];
            if (!isset($result[$key])) {
                $result[$key] = array();
            }

            $result[$key][] = $row;
        }

        // do subsequent group by calls
        if (count($columns)) {
            foreach (array_keys($result) as $key) {
                $result[$key] = $this->groupBy($result[$key], $columns);
            }
        }

        return $result;
    }
956725
private function getRowValues($columns, $data, $rowIndex)
    {
        foreach ($columns as $column) {
            if ($column instanceOf TbDataColumn) {
                $result[$column->name] = $this->getDataCellContent($column, $data, $rowIndex);
            } elseif (is_string($column)) {
                if (is_array($data) && array_key_exists($column, $data)) {
                    $result[$column] = $data[$column];
                } elseif ($data instanceOf CActiveRecord && $data->hasAttribute($column)) {
                    $result[$column] = $data->getAttribute($column);
                } else {
                    throw new CException('Column or attribute "' . $column . '" not found!');
                }
            }
        }
        return isset($result) ? $result : false;
    }
462127
public static function columnToKey($array, $column, $keepOld = true)
    {
        $newArray = [];
        foreach($array as $k => $row)
        {
            $key = $row[$column];
            if(!$keepOld)
            {
                unset($row[$column]);
            }
            $newArray[$key] = $row;
        }
        return $newArray;
    }
924317
public static function sortCol($result,$array)
    {
        foreach ($result as $key => $fields) {
         $dados[] = self::sortkeys($fields,$array);
        }

        if(!$dados){ $dados = [];}

        return $dados;
    }
580165
public function array_fields($array, array $fields){
        $newArray= array();
        foreach ($array as $value) {
            $newValue= array();
            foreach ($fields as $key) {
                if(array_key_exists($key, $value)){
                    $newValue[$key]= $value[$key];
                }
            }
            $newArray[]= $newValue;
        }        
        return $newArray;
    }
1164492
public function arrayCopy(array $array)
    {
        $copy = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $copy[ $key ] = $this->arrayCopy($value);
            } elseif (is_object($value)) {
                $copy[ $key ] = clone $value;
            } else {
                $copy[ $key ] = $value;
            }
        }

        return $copy;
    }
1036492
public static function fieldSort($array, $fields)
    {
        if (!\is_array($fields)) {
            $fields = array($fields);
        }
        self::$temp = $fields;
        $i = 0;
        // restructure the array for sorting.
        //   PHP's uasort is not a "stable sort" (original order not maintained if rows are equal)
        //   if sort values are equal, will sort by temp increment value
        foreach ($array as $k => $row) {
            $array[$k] = array($i++, $row);
        }
        \uasort($array, array(__CLASS__, 'fieldSortFunc'));
        foreach ($array as $k => $row) {
            $array[$k] = $row[1];
        }
        self::$temp = null; // unset($this->temp);
        return $array;
    }
1271414
protected static function arrayGet(array $array, $key)
    {
        $key = strtolower($key);
        $array = array_change_key_case($array, CASE_LOWER);

        if (!array_key_exists($key, $array)) {
            throw new TokenException(
                sprintf('Did not find key %s in array: %s', json_encode($key), json_encode($array))
            );
        }

        return $array[$key];
    }