@param array $array

@return string
427682
public static function arrayToCsv($array)
    {
        if (!is_array($array) || empty($array)) {
            return '';
        }

        $array = array_get($array, ResourcesWrapper::getWrapper(), array_get($array, 'error', $array));
        $data = [];

        if (!isset($array[0])) {
            $data[] = $array;
        } else {
            $data = $array;
        }

        $keys = array_keys(array_get($data, 0, []));

        // currently need to write out to file to use parser
        $tmpDir = rtrim(sys_get_temp_dir(), DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;
        $filename = $tmpDir . 'csv_export' . time() . '.csv';

        $handle = fopen($filename, 'w');

        // build header row
        fputcsv($handle, $keys);

        foreach ($data as $row) {
            foreach ($row as $key => $value) {
                // handle objects and array non-conformist to csv output
                if (is_array($value) || is_object($value)) {
                    $row[$key] = json_encode($value);
                }
            }

            fputcsv($handle, $row);
        }

        fclose($handle);
        $csv = file_get_contents($filename);
        unlink($filename);

        return $csv;
    }
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;
    }
1065925
public static function filterArray($array)
    {
        if (!is_array($array))
        {
            return false;
        }

        $clean = array();
        foreach ($array as $key => $string)
        {
            if (is_array($string))
            {
                self::filterArray($string);
            }
            else
            {
                $string = self::escape($string);
                $key = self::escape($key);
            }
            $clean[$key] = $string;
        }
        return $clean;
    }
487492
private static function formatRequest(&$array)
    {
        if (!isset($array['buyer'])) {
            $array['buyer'] = array();
        }
        if (!isset($array['3DSecure'])) {
            $array['3DSecure'] = array();
        }
        if (!isset($array['bankAccountData'])) {
            $array['bankAccountData'] = array();
        }
        if (!isset($array['cancelURL']) || !strlen($array['cancelURL'])) {
            $array['cancelURL'] = null;
        }
        if (!isset($array['notificationURL']) || !strlen($array['notificationURL'])) {
            $array['notificationURL'] = null;
        }
        if (!isset($array['returnURL']) || !strlen($array['returnURL'])) {
            $array['returnURL'] = null;
        }
        if (!isset($array['languageCode']) || !strlen($array['languageCode'])) {
            $array['languageCode'] = null;
        }
        if (!isset($array['securityMode']) || !strlen($array['securityMode'])) {
            $array['securityMode'] = null;
        }
        if (!isset($array['billingAddress'])) {
            $array['billingAddress'] = array();
        }
        if (!isset($array['shippingAddress'])) {
            $array['shippingAddress'] = array();
        }
        if (!isset($array['owner'])) {
            $array['owner'] = array();
        }
        if (!isset($array['ownerAddress'])) {
            $array['ownerAddress'] = array();
        }
        if (!isset($array['contracts']) || !strlen($array['contracts'][0]) || !is_array($array['contracts'])) {
            $array['contracts'] = null;
        }
        if (!isset($array['secondContracts']) || !strlen($array['secondContracts'][0]) || !is_array($array['secondContracts'])) {
            $array['secondContracts'] = null;
        }
        if (!isset($array['walletContracts']) || !strlen($array['walletContracts'][0]) || !is_array($array['walletContracts'])) {
            $array['walletContracts'] = null;
        }
        if (!isset($array['customPaymentPageCode']) || !strlen($array['customPaymentPageCode'])) {
            $array['customPaymentPageCode'] = null;
        }
        if (!isset($array['customPaymentTemplateURL']) || !strlen($array['customPaymentTemplateURL'])) {
            $array['customPaymentTemplateURL'] = null;
        }
        if (!isset($array['recurring'])) {
            $array['recurring'] = array();
        }
        if (!isset($array['orderRef']) || !strlen($array['orderRef'])) {
            $array['orderRef'] = null;
        }
        if (!isset($array['orderDate']) || !strlen($array['orderDate'])) {
            $array['orderDate'] = null;
        }
        if (!isset($array['walletIds']) || !strlen($array['walletIds'][0] || !is_array($array['walletIds']))) {
            $array['walletIds'] = null;
        }
        if (!isset($array['merchantName'])) {
            $array['merchantName'] = null;
        }
        if (!isset($array['miscData'])) {
            $array['miscData'] = null;
        }
        if (!isset($array['subMerchant'])) {
            $array['subMerchant'] = array();
        }
        if (!isset($array['asynchronousRetryTimeout'])) {
            $array['asynchronousRetryTimeout'] = null;
        }
    }
968776
public function doCredit(array $array)
    {
        $this->formatRequest($array);
        $WSRequest = array(
            'payment'         => $this->payment($array['payment']),
            'card'            => $this->card($array['card']),
            'buyer'           => $this->buyer($array['buyer'], $array['shippingAddress'], $array['billingAddress']),
            'privateDataList' => $this->privateData,
            'order'           => $this->order($array['order']),
            'comment'         => $array['comment'],
            'subMerchant'     => $this->subMerchant($array['subMerchant'])
        );
        return $this->webServiceRequest($array, $WSRequest, self::DIRECT_API, 'doCredit');
    }
1196538
public static function arrayToCss($array){
        $css = '';

        // rebuild CSS
        foreach($array as $key1 => $value1){
            $css .= $key1 . '{';

            foreach($value1 as $key2 => $value2){
                // in the case that the code is embedded in a media query
                if(is_array($value2)){
                    foreach($value2 as $value3){
                        $css .= $key2 . '{';
                        foreach($value3 as $mProp){
                            $css .= $mProp . ':' . $value3 . ';';
                        }
                        $css .= '}';
                    }
                }
                // regular selectors
                else{
                    $css .= $key2 . ':' . $value2 . ';';
                }
            }
            $css .= "}\n";
        }
        return $css;
    }
504731
public static function arrayToRegex($array)
    {
        if (isset($array)) {
            foreach ($array as $k => $item) {
                if(is_string($item)){
                    $array[$k] = $item;
                } else {
                    $array[$k] = "\"".$item."\"";
                }
            }
        }

        return implode('|', $array);
    }
1295173
public function convertArrayToDotNotation(array $array)
    {
        $recursiveIterator = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($array));

        $newArray = [];

        foreach ($recursiveIterator as $leafValue) {
            $keys = [];

            foreach (range(0, $recursiveIterator->getDepth()) as $depth) {
                $keys[] = $recursiveIterator->getSubIterator($depth)->key();
            }

            $newArray[implode('.', $keys)] = $leafValue;
        }

        return $newArray;
    }
409524
public function packMap(array $array)
    {
        $size = count($array);
        $b = '';
        $b .= $this->getMapSizeMarker($size);

        foreach ($array as $k => $v) {
            $b .= $this->pack($k);
            $b .= $this->pack($v);
        }

        return $b;
    }
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);
    }
569575
protected function sequentialArrayToKey(array $array)
    {

        if ($this->isObjectAndId($array)) {
            return get_class($array[0]) . '-' . $array[1];
        }

        $parts = [];

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

        return implode('_', $parts);
    }
514712
public function doDebit(array $array)
    {
        $this->formatRequest($array);
        $WSRequest = array(
            'payment'                => $this->payment($array['payment']),
            'card'                   => $this->card($array['card']),
            'order'                  => $this->order($array['order']),
            'privateDataList'        => $this->privateData,
            'buyer'                  => $this->buyer($array['buyer'], $array['shippingAddress'], $array['billingAddress']),
            'authentication3DSecure' => $this->authentication3DSecure($array['3DSecure']),
            'authorization'          => $this->authorization($array['authorization']),
            'subMerchant'            => $this->subMerchant($array['subMerchant'])
        );
        return $this->webServiceRequest($array, $WSRequest, self::DIRECT_API, 'doDebit');
    }
643916
public static function quoteStrings(array $array)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return null;
        }

        $result = [];

        foreach ($array as $index => $value) {
            if (is_array($value)) {
                $value = self::quoteStrings($value);
            } elseif (is_string($value)) {
                if (!Regex::isQuoted($value)) {
                    $value = '\'' . $value . '\'';
                }
            }

            $result[$index] = $value;
        }

        return $result;
    }
945027
protected function getArrayType(array $array) {
		$indices = count(array_filter(array_keys($array), 'is_string'));

		if ($indices == 0) {
			$type = self::ARRAY_TYPE_LIST;
		} elseif ($indices == count($array)) {
			$type = self::ARRAY_TYPE_DICT;
		} else {
			$type = self::ARRAY_TYPE_MIXED;
		}

		return $type;
	}
615820
public function expandArray($array)
    {
        $retval = "";
        for ($i = 0; $i < count($array); $i++) {
            $retval .= $this->expandString($array[$i]);
        }

        return $retval;
    }
1044584
public static function trimRecursive(array $array)
    {
        /*
         * No elements?
         * Nothing to do
         */
        if (empty($array)) {
            return [];
        }

        $result = [];

        foreach ($array as $key => $value) {
            if (is_array($value)) {
                $result[$key] = self::trimRecursive($value);

                continue;
            }

            if (is_string($value)) {
                $value = trim($value);
            }

            $result[$key] = $value;
        }

        return $result;
    }
850335
public static function buildAndCondition(array $array)
    {   
        $str = ''; 
        foreach ($array as $key => $val) {
            $kv = "{$key}='{$val}'";
            $str .= $str ? ' AND ' . $kv : $kv;
        }
        return $str;
    }