PhpOrient\Protocols\Binary\Serialization\CSV::serializeArray PHP Method

serializeArray() protected static method

If the array is associative a map will be returned, otherwise a plain array.
protected static serializeArray ( array $array ) : string
$array array the array to serialize
return string the serialized array or map.
    protected static function serializeArray(array $array)
    {
        $isMap = false;
        $keys = [];
        $values = [];
        foreach ($array as $key => $value) {
            if (!$isMap && is_string($key) && strlen($key)) {
                $isMap = true;
            }
            if ($isMap) {
                $keys[] = '"' . str_replace('"', '\\"', str_replace('\\', '\\\\', $key)) . '"';
            } else {
                $keys[] = '"' . $key . '"';
            }
            $values[] = self::serialize($value, true);
        }
        if ($isMap) {
            $parts = [];
            foreach ($keys as $i => $key) {
                $parts[] = $key . ':' . $values[$i];
            }
            return '{' . implode(',', $parts) . '}';
        } else {
            return '[' . implode(',', $values) . ']';
        }
    }