Convert an array in a string CSV

@param array  $array
@param bool   $header_row
@param string $col_sep
@param string $row_sep
@param string $qut

@return string
553325
public static function arrayToCsv($array, $header_row = true, $col_sep = ",", $row_sep = "\n", $qut = '"')
    {
        if (!is_array($array) || !isset($array[0]) || !is_array($array[0])) {
            return false;
        }
        $output = '';
        if ($header_row) {
            foreach ($array[0] as $key => $val) {
                $key = str_replace($qut, "$qut$qut", $key);
                $output .= "$col_sep$qut$key$qut";
            }
            $output = substr($output, 1)."\n";
        }
        foreach ($array as $key => $val) {
            $tmp = '';
            foreach ($val as $cell_key => $cell_val) {
                $cell_val = str_replace($qut, "$qut$qut", $cell_val);
                $tmp .= "$col_sep$qut$cell_val$qut";
            }
            $output .= substr($tmp, 1).$row_sep;
        }

        return $output;
    }
42542
public static function arrayUnflattenDotNotation($array, $separator = '.')
    {
        $newArray = [];
        foreach ($array as $key => $value) {
            $dots = explode($separator, $key);
            if (\count($dots) > 1) {
                $last = &$newArray[$dots[0]];
                foreach ($dots as $k => $dot) {
                    if ($k === 0) {
                        continue;
                    }
                    $last = &$last[$dot];
                }
                $last = $value;
            } else {
                $newArray[$key] = $value;
            }
        }

        return $newArray;
    }
860561
public function arrayToTable(array $array, array $options = []): string
    {
        $table = '<table class="table table-condensed';
        if (isset($options['class'])) {
            $table .= ' ' . $options['class'] . ' ';
        }
        $table .= '">';

        foreach ($array as $fieldname => $value) {
            if (is_callable($options['fieldnameCallback'])) {
                $callback = $options['fieldnameCallback'];
                $fieldname = $callback($fieldname);
            }

            $table .= '<tr>';
                $table .= '<td>' . $fieldname . '</td>';
            if (is_array($value)) {
                $table .= '<td>' . $this->arrayToTable($value, $options) . '</td>';
            } else {
                if ($value === null) {
                    $value = 'NULL';
                }
                $table .= '<td>' . $value . '</td>';
            }
            $table .= '</tr>';
        }
        $table .= '</table>';

        return $table;
    }
313037
public static function camelize(array $array, string $delimiter = '_', bool $lcfirst = true)
    {
        foreach ($array as $key => $value) {
            $k = $key;
            $k = Text::camelize($k);
            $lcfirst && $k = lcfirst($k);
            if ($key != $k) {
                unset($array[$key]);
            }
            if (is_array($value)) {
                $value = static::camelize($value, $delimiter, $lcfirst);
            }
            $array[$k] = $value;
        }
        return $array;
    }
1093868
static public function stringify(array $array)
    {
        $result = array();
        foreach ($array as $key => $value) {
            $result[] = sprintf('%s=%s', $key, $value);
        }
        return implode('&', $result);
    }
1234391
private static function dumpArray(array $array) {
    $str = "[";
    foreach ($array as $value) {
      if (is_object($value)) {
        $str .= $value->__toString().", ";
      }
      else {
        $str .= $value.", ";
      }
    }
    $str = preg_replace("/, $/", "", $str)."]";
    return $str;
  }
1323949
protected function arrayTable($arr, array $header = [ 'Key', 'Value' ])
    {

        $rows = [ ];
        foreach ($arr as $key => $val) {
            if (is_array($val)) {
                $val = print_r(array_slice($val, 0, 5), true);
            }
            $rows[] = [ (string)$key, (string)$val ];
        }
        $this->table($header, $rows);
    }
376001
private static function array_to_json($array) {
		if (! is_array ( $array )) {
			throw new BCS_Exception ( "Param must be array in function array_to_json()", - 1 );
		}
		self::array_recursive ( $array, 'addslashes', false );
		self::array_recursive ( $array, 'rawurlencode', false );
		return rawurldecode ( json_encode ( $array ) );
	}
1269951
protected function serializeFields(array $row)
    {
        $data    = array();
        $columns = $this->getColumns();

        $builder = $this->newQueryBuilder($this->getName());
        $parts   = $builder->getQueryPart('from');
        $part    = reset($parts);
        $alias   = $part['alias'];

        foreach ($columns as $name => $type) {
            if (!empty($alias)) {
                $pos = strpos($name, $alias . '.');
                if ($pos !== false) {
                    $name = substr($name, strlen($alias) + 1);
                }
            }

            if (isset($row[$name])) {
                $data[$name] = $this->serializeType($row[$name], $type);
            }
        }

        return $data;
    }
1162492
public function fromArray(array $array) {
        $rows = count($array);
        for ($i=$rows;$i-->0;) {
            $this[$i]->fromArray($array[$i]);
        }
    }
368932
public static function toUnderscore(array $array = [])
    {
        $output = [];
        foreach ($array as $key => $value) {
            $key = StringUtils::toUnderscore($key);
            if (is_array($value)) {
                $value = static::toUnderscore($value);
            }
            $output[$key] = $value;
        }

        return $output;
    }
958395
public static function arrayToString(array $array, $delimiter = ""): string {
        $string = "";
        foreach ($array as $value) {
            if (\is_array($value)) {
                $string .= ArrayUtil::arrayToString($value, $delimiter) . $delimiter;
            } else {
                $string .= $value . $delimiter;
            }
        }
        return $string;
    }
724268
public static String join(final Object array, final String separator) {

    return isArray(array) ? join(toArray(array, ClassUtils.getComponentClass(array)), separator)
      : Objects.toString(array);
  }
470303
protected function implodeArray(array $array)
    {
        $results = [];

        foreach ($array as $key => $value) {
            if (is_string($key)) {
                $results[] = "'".$key."' => '".$value."'";
            } else {
                $results[] = "'".$value."'";
            }
        }

        return count($results) > 0 ? implode(', ', $results) : '';
    }
574563
public static function arrayToStr($array)
    {
        if(!is_array($array))
            return "".$array;

        $string_parts = array ();

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $string_parts[] = "[$key] => ( " . self::arrayToStr($value) . " )";
            } else if (is_object($value)) {
                $string_parts[] = "[$key] => ".get_class($value);
            } else {
                $string_parts[] = "[$key] => $value";
            }
        }

        return join(', ', $string_parts);
    }
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;
	}
1117818
public function copyToArray(array &$array)
    {
        $array['formatted']      = $this->formatted;
        $array['street_address'] = $this->streetAddress;
        $array['locality']       = $this->locality;
        $array['region']         = $this->region;
        $array['postal_code']    = $this->postalCode;
        $array['country']        = $this->country;
    }