Clean-param

@param string[][] $array
@return string[]
547945
private function buildCleanParam($array)
    {
        $result = [];
        foreach ($array as $param => $paths) {
            foreach ($paths as $path) {
                $result[] = self::DIRECTIVE_CLEAN_PARAM . ':' . $param . ' ' . $path;
            }
        }
        return $result;
    }
728942
private function formatToParameters($array)
    {
        if (empty($array)) {
            return [];
        }

        $defaultDirection = config('columnsortable.default_direction', 'asc');

        if (is_string($array)) {
            return ['sort' => $array, 'direction' => $defaultDirection];
        }

        return (key($array) === 0) ? ['sort' => $array[0], 'direction' => $defaultDirection] : [
            'sort'      => key($array),
            'direction' => reset($array),
        ];
    }
1000662
public static function trim_array($array)
    {

        if (empty($array) || !is_array($array)) return $array;

        foreach ($array as $key => $value) {
            $array[$key] = trim($value);
        }

        unset($key, $value);

        return $array;
    }
631759
public static function removeEmptyStrings($array)
    {
        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $array[$key] = self::removeEmptyStrings($value);
                
                if (empty($array[$key])) {
                    unset($array[$key]);
                }
            } elseif ($value === '') {
                unset($array[$key]);
            }
        }
        
        return $array;
    }
467192
public static function arrayToList(array $array = array())
    {
        $return = array();
        foreach ($array as $name => $email) {
            $return[] = empty($name) || General::intval($name) > -1
                        ? $email
                        : $name . ' <' . $email . '>';
        }

        return implode(', ', $return);
    }
484728
public static function clean( $array = null, $callback = null )
    {
        $_result = ( empty( $array ) ? array() : ( !is_array( $array ) ? array($array) : $array ) );

        if ( null === $callback || !is_callable( $callback ) )
        {
            return $_result;
        }

        $_response = array();

        foreach ( $_result as $_item )
        {
            $_response[] = call_user_func( $callback, $_item );
        }

        return $_response;
    }
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;
    }
329772
public function flatAssocArray(array $array)
	{
		$ret = [];
		foreach ($array as $key => $value) {
			if (is_array($value)) {
				$ret += $this->flatAssocArray($value);
			}
			else {
				$ret[ $key ] = $value;
			}
		}

		return $ret;
	}
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;
  }
80310
public static function arrayToMask($array)
    {
        $mask = self::NONE_MASK;

        if (empty($array) || !is_array($array)) {
            return $mask;
        }

        foreach ($array as $verb) {
            switch ($verb) {
                case self::GET:
                    $mask |= self::GET_MASK;
                    break;
                case self::POST:
                    $mask |= self::POST_MASK;
                    break;
                case self::PUT:
                    $mask |= self::PUT_MASK;
                    break;
                case self::PATCH:
                    $mask |= self::PATCH_MASK;
                    break;
                case self::DELETE:
                    $mask |= self::DELETE_MASK;
                    break;
                case self::OPTIONS:
                    $mask |= self::OPTIONS_MASK;
                    break;
                case self::HEAD:
                    $mask |= self::HEAD_MASK;
                    break;
                case self::COPY:
                    $mask |= self::COPY_MASK;
                    break;
                case self::TRACE:
                    $mask |= self::TRACE_MASK;
                    break;
                case self::CONNECT:
                    $mask |= self::CONNECT_MASK;
                    break;
            }
        }

        return $mask;
    }
239692
private function getArrayValue(array $array)
    {
        $value = [];
        foreach ($array as $item) {
            if ($item instanceof Keyword) {
                $item = $this->getKeyword($item);
            }
            $value[] = trim(str_replace(array("\n", "\r"), '', strip_tags('' . $item)));
        }

        array_walk($value, function(&$item) { return trim(str_replace(array("\n", "\r"), '', strip_tags('' . $item))); });

        return implode(',', array_filter($value));
    }
640184
static public function toLowerCaseKey(array $array)
	{
	    $res = [];
	    if ($array) {
	        foreach ($array as $k  => $v) {
	            if (is_array($v)) {
	                $v = static::toLowerCaseKey($v);
	            }
	            $res[strtolower($k)] = $v;
	        }
	    }
	    return $res;
	}
148717
protected function purgeArray(array $array = array()) {

        $result = array();
        $keys   = array_keys($array);

        $this->addBasicPurgeFilters();

        if (!empty($keys) && !empty($this->purgeFilters)) {
            foreach ($keys as $key) {
                $allowed = true;

                foreach ($this->purgeFilters as $filter) {
                    $allowed = $filter($key);

                    if (!$allowed) {
                        break;
                    }
                }

                if ($allowed) {
                    $result[$key] = $array[$key];
                }
            }
        }

        return $result;
    }
1055647
private function trimArray(&$array)
    {
        foreach ($array as $key => $value) {
            if (is_string($value)) {
                $array[$key] = trim($value);
            } else if (is_array($value)) {
                $array[$key] = $this->trimArray($value);
            }
        }

        return $array;
    }
776918
public function arrayFilterRecursive(array $array)
    {
        foreach ($array as &$value) {
            if (is_array($value)) {
                /** @var $value array */
                $value = count($value) === 1 && array_key_exists(0, $value) && is_string($value[ 0 ]) &&
                $this->variable->isEmpty(trim($value[ 0 ])) ? $value[ 0 ] : $this->arrayFilterRecursive($value);
            }
        }

        return array_filter($array, function ($value) {
            return ! $this->variable->isEmpty($value) &&
                ! (is_string($value) && $this->variable->isEmpty(trim($value)));
        });
    }
757879
protected function removeNullElements($array)
    {
        foreach ($array as $key => $val) {
            if (is_array($val)) {
                $array[$key] = $this->removeNullElements($val);
            } elseif (is_null($val)) {
                unset($array[$key]);
            }
        }

        return $array;
    }
162994
public static function flat(array $array)
    {
        $out = [];
        foreach ($array as $key=>$value) {
            if (is_array($value)) {
                //use recursion to get to the next array
                $out = array_merge($out, self::flat($value));
            } else {
                //add the value to the back of the array
                //if the value is not an array
                $out[] = $value;
            }
        }
        //return the resulting array
        return $out;
    }