Method to build a string with xml style attributes from  an array of key/value pairs

@param   mixed   $array The array of Key/Value pairs for the attributes
@return  string  String containing xml style attributes
490333
public function buildAttributes($array)
    {
        $output = array();

        if ($array instanceof KObjectConfig) {
            $array = KObjectConfig::unbox($array);
        }

        if (is_array($array))
        {
            foreach ($array as $key => $item)
            {
                if (is_array($item)) {
                    $item = implode(' ', $item);
                }

                if (is_bool($item))
                {
                    if ($item === false) continue;
                    $item = $key;
                }

                $output[] = $key . '="' . str_replace('"', '&quot;', $item) . '"';
            }
        }

        return implode(' ', $output);
    }
730150
protected function doCreateObject(array $array)
    {
        $raw = [];
        foreach ($array as $item) {
            $raw[$item['attributeId']]['id']               = $item['attributeId'];
            $raw[$item['attributeId']]['title']            = $item['title'];
            $raw[$item['attributeId']]['code']             = $item['code'];
            $raw[$item['attributeId']]['cssClass']         = $item['cssClass'];
            $raw[$item['attributeId']]['orderNumber']      = $item['orderNumber'];
            $raw[$item['attributeId']]['showInSpecList']   = $item['showInSpecList'];
            $raw[$item['attributeId']]['useInFilter']      = $item['useInFilter'];
            $raw[$item['attributeId']]['description']      = $item['description'];
            $raw[$item['attributeId']]['attributeGroupId'] = $item['attributeGroupId'];
            $raw[$item['attributeId']]['displayType']      = $item['displayType'];

            $raw[$item['attributeId']]['attributeValues'][] = [
                'id'     => $item['id'],
                'value'  => $item['value'],
                'cssClass' => $item['cssClass'],
                'title'  => $item['valueTitle'],
                'amount' => $item['amount'],
                'orderNumber' => $item['orderNumberAttributeValues'] ?? null
            ];
        }

        $mapper = new AttributesMapper();
        $result = [];
        foreach ($raw as $item) {
            $result[] = $mapper->createObject($item);
        }

        return $result;
    }
1093868
static public function stringify(array $array)
    {
        $result = array();
        foreach ($array as $key => $value) {
            $result[] = sprintf('%s=%s', $key, $value);
        }
        return implode('&', $result);
    }
1374498
protected function buildMapDefinitions(array $array) {
		$result = [];
		foreach ($array as $alias => $value) {
			$result[] = "\t\t\t" . "'" . str_replace("'", "\'", $alias) . "' => " . $value . ',';
		}

		return implode(PHP_EOL, $result);
	}
147548
public static function buildXml(SimpleXMLElement &$xml, $array) {
        if (is_array($array)) {
            foreach ($array as $key => $value) {

                // XML_NONE
                if (!is_array($value)) {
                    $xml->addChild($key, static::unbox($value));
                    continue;
                }

                // Multiple nodes of the same name
                if (Hash::isNumeric(array_keys($value))) {
                    foreach ($value as $kValue) {
                        if (is_array($kValue)) {
                            static::buildXml($xml, array($key => $kValue));
                        } else {
                            $xml->addChild($key, static::unbox($kValue));
                        }
                    }

                // XML_GROUP
                } else if (isset($value['attributes'])) {
                    if (!isset($value['value'])) {
                        $value['value'] = null;
                    }

                    if (is_array($value['value'])) {
                        $node = $xml->addChild($key);
                        static::buildXml($node, $value['value']);
                    } else {
                        $node = $xml->addChild($key, static::unbox($value['value']));
                    }

                    if (!empty($value['attributes'])) {
                        foreach ($value['attributes'] as $aKey => $aValue) {
                            $node->addAttribute($aKey, static::unbox($aValue));
                        }
                    }

                // XML_MERGE
                } else if (isset($value['value'])) {
                    $node = $xml->addChild($key, $value['value']);
                    unset($value['value']);

                    if (!empty($value)) {
                        foreach ($value as $aKey => $aValue) {
                            if (is_array($aValue)) {
                                static::buildXml($node, array($aKey => $aValue));
                            } else {
                                $node->addAttribute($aKey, static::unbox($aValue));
                            }
                        }
                    }

                // XML_ATTRIBS
                } else {
                    $node = $xml->addChild($key);

                    if (!empty($value)) {
                        foreach ($value as $aKey => $aValue) {
                            if (is_array($aValue)) {
                                static::buildXml($node, array($aKey => $aValue));
                            } else {
                                $node->addChild($aKey, static::unbox($aValue));
                            }
                        }
                    }
                }
            }
        }

        return $xml;
    }
1202589
protected function createArrayType($array)
    {
        $type = new ArrayAccessType;

        foreach ($array as $key=>$value) {
            $type[$key] = $this->toType($value);
        }

        return $type;
    }
775455
private static function __s_array($array)
    {
        $border    = new Border(Border::TYPE_FRAME);
        $structure = new Structure(Structure::TYPE_ARRAY, '', null, '|', $border);

        return static::buildStructure($array, $structure);
    }
693262
public static function keyedArray($array) {
        if(is_array($array)) {
            $string = '[ ';
            foreach($array as $key => $item) {
                if(!is_string($item)) {
                    $item = self::keyedArray($item);
                }
                $string .= $key . ' => ' . $item;
                if($item !== last($array)) {
                    $string .= ', ';
                }
            }
            $string .= ' ]';

            return $string;
        } else {
            if(is_object($array)) {
                return get_class($array);
            } else {
                if(is_null($array)) {
                    return 'Null';
                } else {
                    return 'Unknown';
                }
            }
        }
    }
1332793
protected function renderDataTableSimple($array, $prefixLine = "")
    {
        if (!is_array($array)) {
            $array = array('value' => $array);
        }

        $columnsHaveInvalidChars = $this->areTableLabelsInvalidXmlTagNames($array);

        $out = '';
        foreach ($array as $keyName => $value) {
            $xmlValue = self::formatValueXml($value);
            list($tagStart, $tagEnd) = $this->getTagStartAndEndFor($keyName, $columnsHaveInvalidChars);
            if (strlen($xmlValue) == 0) {
                $out .= $prefixLine . "\t<$tagStart />\n";
            } else {
                $out .= $prefixLine . "\t<$tagStart>" . $xmlValue . "</$tagEnd>\n";
            }
        }
        return $out;
    }
1253093
public function getStyleArray($array)
	{
		switch ($this->_parentPropertyName) {
			case '_endColor':
				$key = 'endcolor';
				break;
			case '_color':
				$key = 'color';
				break;
			case '_startColor':
				$key = 'startcolor';
				break;

		}
		return $this->_parent->getStyleArray(array($key => $array));
	}
84647
public static function expandDotNotationKeys(Array $array)
    {
        $result = [];

        foreach ($array as $key => $value) {
          array_set($result, $key, $value);
        }

        return $result;
    }
273312
private static function encodeArray(array $array)
    {
        // If it is an associative array, treat it as an object.
        if (!empty($array) && array_keys($array) !== range(0, count($array) - 1)) {
            return self::encodeMap($array);
        }

        // Differentiate on the array length.
        if (count($array) < 16) {
            // fixarray
            $prefix = bindec(1001) * 16 + count($array);
        } elseif (count($array) < pow(2, 16)) {
            // array 16
            $prefix = 0xdc * 256 * 256;
            $prefix += count($array);
        } elseif (count($array) < pow(2, 32)) {
            // array 32
            $prefix = 0xdd * 256 * 256 * 256 * 256;
            $prefix += count($array);
        } else {
            throw new UnencodeableException('Array with more then 2^32 elements included cannot be encoded.', 1);
        }

        // Byte encode it.
        $result = pack('H*', dechex($prefix));

        // Loop every item of the array.
        foreach (array_values($array) as $item) {
            // Concatenate everything.
            $result .= self::encode($item);
        }

        // Return the result.
        return $result;
    }
1348631
public function getAttributeNamesFromColumns($array)
    {
        if (!empty($this->mappings)) {
            $newArray = [];
            foreach ($array as $key => $value) {
                $attributeName = isset($this->mappings[$key]) ? $this->mappings[$key] : $key;
                $newArray[$attributeName] = $value;
            }

            return $newArray;
        }

        return $array;
    }
610150
public function pureDump(array $array): string
    {
        $xml = new ArrayToXml(
            $array,
            [
                '_attributes' => $this->options['rootAttr'],
                'rootElementName' => $this->options['root'],
            ],
            $this->options['keySpaceToUnderscore']
        );

        $dom = $xml->toDom();
        $dom->xmlVersion = $this->options['version'];
        $dom->encoding = $this->options['encoding'];
        $dom->formatOutput = !$this->options['minify'];

        return $dom->saveXML();
    }
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;
    }
420174
public function localeAttribute(array $array, string $attribute)
    {
        $locale = $this->requestStack->getCurrentRequest()->getLocale();

        return isset($array[$attribute.$locale]) ? $array[$attribute.$locale] : '';
    }
1039283
public static function generateValidXmlFromArray($array, $nodeBlock = 'nodes', $nodeNames = [])
    {
        if (is_string($nodeNames)) {
            $nodeNames = ['__global' => $nodeNames];
        }
        if (!isset($nodeNames['__global'])) {
            $nodeNames['__global'] = current($nodeNames);
        }
        $xml = '<?xml version="1.0" encoding="UTF-8" ?>';
        $xml .= '<' . $nodeBlock . '>';
        $xml .= self::generateXmlFromArray($array, $nodeNames, $nodeBlock);
        $xml .= '</' . $nodeBlock . '>';

        return $xml;
    }